SQL 为字段值为空的项添加值

来源:百度知道 编辑:UC知道 时间:2024/05/28 17:43:35
在表POST中,有很多字段,很多行数据,有一些行中的字段PostDate项中为空值,我想把字段PostDate中为空的添加上数据,比如添加的值为:2007-7-8 14:20:28
这个语句怎么写呢?

update post set postdate='2007-7-8 14:20:28' where postdate is null

合法的日期字符串可以直接赋值给日期型字段,不用显示转换.

啥数据库啊?oracle可以这样
update POST set postDate = to_date('2007-7-8 14:20:28’,'yyyy-mm-dd hh24:mi:ss') where PostDate is null

update POST
set PostDate= to_Date('2007-7-8 14:20:28’,'yyyy-mm-dd hh24:mi:ss') where PostDate is null

update from tableName
set postDate = to_date('2007-7-8 14:20:28’,'yyyy-mm-dd hh24:mi:ss') where PostDate = null

update POST set PostDate='2007-7-08 14:20:28' where PostDate is null

update post set postdate = to_date('yyyy-MM-dd hh:mm:ss','2007-7-8 14:20:28’) where postdate is null