
您可以借助 update 命令为一列所有记录设置值。
如果您想为一列中的所有记录设置 NULL 值,语法如下 -
update yourTableName set yourColumnName = NULL;
或者,如果您想使用空字符串,则语法如下 -
update yourTableName set yourColumnName = ’’;
为了理解上述概念,让我们创建一个表。创建表的查询。
mysql> create table StudentDemo −> ( −> Studentid int, −> StudentName varchar(100), −> Age int −> ); Query OK, 0 rows affected (0.64 sec)
下面是插入记录的表 -
mysql> insert into StudentDemo values(1,'Johnson',23); Query OK, 1 row affected (0.18 sec) mysql> insert into StudentDemo values(2,'Carol',24); Query OK, 1 row affected (0.16 sec) mysql> insert into StudentDemo values(3,'David',20); Query OK, 1 row affected (0.18 sec) mysql> insert into StudentDemo values(4,'Bob',21); Query OK, 1 row affected (0.19 sec)
借助 select 语句显示表中的所有记录 -
Scala也是一种函数式语言,其函数也能当成值来使用。Scala提供了轻量级的语法用以定义匿名函数,支持高阶函数,允许嵌套多层函数,并支持柯里化 。Scala的Case Class及其内置的模式匹配相当于函数式编程语言中常用的代数类型(Algebraic Type)。 Scala课堂是Twitter启动的一系列讲座,用来帮助有经验的工程师成为高效的Scala 程序员。Scala是一种相对较新的语言,但借鉴了许多熟悉的概念。因此,课程中的讲座假设听众知道这些概念,并展示了如何在Scala中使用它们。我们发现
0
mysql> select *from StudentDemo;
以下是输出 -
+-----------+-------------+------+ | Studentid | StudentName | Age | +-----------+-------------+------+ | 1 | Johnson | 23 | | 2 | Carol | 24 | | 3 | David | 20 | | 4 | Bob | 21 | +-----------+-------------+------+ 4 rows in set (0.00 sec)
以下查询将特定列中的所有记录的列值设置为 NULL。查询如下 -
mysql> update StudentDemo set Age=NULL; Query OK, 4 rows affected (0.14 sec) Rows matched: 4 Changed: 4 Warnings: 0
现在让我们检查一下 -
mysql> select *from StudentDemo;
以下输出显示我们已成功将“Age”列更新为 NULL -
+-----------+-------------+------+ | Studentid | StudentName | Age | +-----------+-------------+------+ | 1 | Johnson | NULL | | 2 | Carol | NULL | | 3 | David | NULL | | 4 | Bob | NULL | +-----------+-------------+------+ 4 rows in set (0.00 sec)
以上就是为 MySQL 表中的列设置类似的值?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号