MySQL时间类型-1
(1)当前日期类型
mysql> create table thetime(t date);
Query OK, 0 rows affected (0.09 sec)
mysql> insert into thetime values(now());
Query OK, 1 row affected, 1 warning (0.06 sec)
mysql> select * from thetime;
+------------+
| t |
+------------+
| 2013-04-28 |
+------------+
1 row in set (0.00 sec)
mysql>
(2)当前时间类型
mysql> create table thetime(t time);
Query OK, 0 rows affected (0.11 sec)
mysql> insert into thetime values(now());
Query OK, 1 row affected (0.30 sec)
mysql> select * from thetime;
+----------+
| t |
+----------+
| 00:56:30 |
+----------+
1 row in set (0.00 sec)
mysql>
(3)当前日期和时间类型
mysql> create table thetime(t datetime);
Query OK, 0 rows affected (0.11 sec)
mysql> insert into thetime values(now());
Query OK, 1 row affected (0.09 sec)
mysql> select * from thetime;
+---------------------+
| t |
+---------------------+
| 2013-04-28 00:56:54 |
+---------------------+
1 row in set (0.00 sec)
mysql>
(4)获取当前日期和时间
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2013-04-28 01:02:58 |
+---------------------+
1 row in set (0.00 sec)
mysql>
总结:datetime(当前日期和时间) = date(当前日期) + time(当前时间)。