在MySQL中创建带有日期的临时表
要创建带有日期的临时表,请在MySQL中使用CREATETEMPORARYTABLE。以下是语法-
语法
create temporary table yourTableName( yourColumnName datetime );
让我们首先创建一个表-
mysql> create temporary table DemoTable -> ( -> DueDate datetime -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values(now()); mysql> insert into DemoTable values(curdate()); mysql> insert into DemoTable values('2018-01-21'); mysql> insert into DemoTable values('2019-12-31');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+---------------------+ | DueDate | +---------------------+ | 2019-10-27 18:07:41 | | 2019-10-27 00:00:00 | | 2018-01-21 00:00:00 | | 2019-12-31 00:00:00 | +---------------------+ 4 rows in set (0.00 sec)