让我们首先创建一个表-
mysql> create table DemoTable1903 ( FirstName varchar(20), LastName varchar(20) , Age int );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1903 values('John','Smith',23); mysql> insert into DemoTable1903 values('None','Miller',28); mysql> insert into DemoTable1903 values('None','Taylor',26); mysql> insert into DemoTable1903 values('Chris','Brown',26);
使用select语句显示表中的所有记录-
mysql> select * from DemoTable1903;
这将产生以下输出-
+-----------+----------+------+ | FirstName | LastName | Age | +-----------+----------+------+ | John | Smith | 23 | | None | Miller | 28 | | None | Taylor | 26 | | Chris | Brown | 26 | +-----------+----------+------+ 4 rows in set (0.00 sec)
这是更新列名并使用N / A设置NONE的查询-
mysql> update DemoTable1903 set FirstName='N/A' where FirstName='None'; Rows matched: 2 Changed: 2 Warnings: 0
让我们再次检查表记录-
mysql> select * from DemoTable1903;
这将产生以下输出-
+-----------+----------+------+ | FirstName | LastName | Age | +-----------+----------+------+ | John | Smith | 23 | | N/A | Miller | 28 | | N/A | Taylor | 26 | | Chris | Brown | 26 | +-----------+----------+------+ 4 rows in set (0.00 sec)