返回顶部

收藏

mysql TIMESTAMP 数据类型使用示例

更多
mysql>
mysql> CREATE TABLE IF NOT EXISTS user_log
    -> (
    ->   id INT,
    ->   date TIMESTAMP,
    ->   first_name VARCHAR(20),
    ->   last_name  VARCHAR(20)
    -> );
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> # confirm the "user_log" table format
mysql> EXPLAIN user_log;
+------------+-------------+------+-----+-------------------+-----------------------------+
| Field      | Type        | Null | Key | Default           | Extra                       |
+------------+-------------+------+-----+-------------------+-----------------------------+
| id         | int(11)     | YES  |     | NULL              |                             |
| date       | timestamp   | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| first_name | varchar(20) | YES  |     | NULL              |                             |
| last_name  | varchar(20) | YES  |     | NULL              |                             |
+------------+-------------+------+-----+-------------------+-----------------------------+
4 rows in set (0.00 sec)

mysql>
mysql> # delete this sample table
mysql> DROP TABLE user_log;
Query OK, 0 rows affected (0.00 sec)

标签:MySQL,timestamp

收藏

0人收藏

支持

0

反对

0

发表评论