批量更改MySQL中特定字段的所有条目?
让我们首先创建一个演示表-
mysql> create table BulkChangeDemo-> (
-> CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> CustomerName varchar(20),
-> isEducated boolean
-> );
使用insert命令在表中插入一些记录。查询如下-
mysql> insert into BulkChangeDemo(CustomerName,isEducated) values('Larry',true);mysql> insert into BulkChangeDemo(CustomerName,isEducated) values('John',false);
mysql> insert into BulkChangeDemo(CustomerName,isEducated) values('Carol',false);
mysql> insert into BulkChangeDemo(CustomerName,isEducated) values('Mike',true);
mysql> insert into BulkChangeDemo(CustomerName,isEducated) values('David',false);
mysql> insert into BulkChangeDemo(CustomerName,isEducated) values('Bob',false);
使用select语句显示表中的所有记录。查询如下-
mysql> select *from BulkChangeDemo;
这是输出-
+------------+--------------+------------+| CustomerId | CustomerName | isEducated |
+------------+--------------+------------+
| 1 | Larry | 1 |
| 2 | John | 0 |
| 3 | Carol | 0 |
| 4 | Mike | 1 |
| 5 | David | 0 |
| 6 | Bob | 0 |
+------------+--------------+------------+
6 rows in set (0.00 sec)
以下是查询以批量更改特定字段的所有条目-
mysql> update BulkChangeDemo set isEducated =true;Rows matched: 6 Changed: 4 Warnings: 0
以上是 批量更改MySQL中特定字段的所有条目? 的全部内容, 来源链接: utcz.com/z/340884.html