MySQL DATE类型

mysql> use test;

Database changed

mysql> create table teacher(birthday DATE);

Query OK, 0 rows affected (0.24 sec)



mysql> desc teacher;

+----------+------+------+-----+---------+-------+

| Field    | Type | Null | Key | Default | Extra |

+----------+------+------+-----+---------+-------+

| birthday | date | YES  |     | NULL    |       |

+----------+------+------+-----+---------+-------+

1 row in set (0.87 sec)



# 以'-'作为分隔符

mysql> insert into teacher values('1972-09-23');

Query OK, 1 row affected (0.07 sec)



# 以'@'作为分隔符

mysql> insert into teacher values('1981@4@12');

Query OK, 1 row affected (0.05 sec)



# 以'/'作为分隔符

mysql> insert into teacher values('1987/8/17');

Query OK, 1 row affected (0.00 sec)



mysql> insert into teacher values(20080808);

Query OK, 1 row affected (0.04 sec)



mysql> select * from teacher;

+------------+

| birthday   |

+------------+

| 1972-09-23 |

| 1981-04-12 |

| 1987-08-17 |

| 2008-08-08 |

+------------+

4 rows in set (0.00 sec)



mysql>

 

你可能感兴趣的:(mysql)