Table with TIMESTAMP data type
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)
Related examples in the same category