让我们首先创建一个表-
create table DemoTable1451 -> ( -> JoiningDate date -> );
使用插入命令在表中插入一些记录-
insert into DemoTable1451 values('2019-07-21'); insert into DemoTable1451 values('2018-01-31'); insert into DemoTable1451 values('2017-06-01');
使用select语句显示表中的所有记录-
select * from DemoTable1451;
这将产生以下输出-
+-------------+ | JoiningDate | +-------------+ | 2019-07-21 | | 2018-01-31 | | 2017-06-01 | +-------------+ 3 rows in set (0.00 sec)
这是更新日期类型列的查询。我们将日期记录增加一年-
update DemoTable1451 set JoiningDate=date_add(JoiningDate, interval 1 year); Rows matched: 3 Changed: 3 Warnings: 0
让我们再次检查表记录-
select * from DemoTable1451;
这将产生以下输出-
+-------------+ | JoiningDate | +-------------+ | 2020-07-21 | | 2019-01-31 | | 2018-06-01 | +-------------+ 3 rows in set (0.00 sec)