# 时间默认值
Joe 写了一个订单表的创建语句:
```sql
create table orders (
id int primary key auto_increment,
item_id int,
amount int,
unit_price decimal(12, 4),
price decimal(12, 4)
);
```
现在,Joe 需要给这个表加入下单时间,即订单写入数据库的时间,那么他应该将这个语句修改为:
点击进入[MySQL实战练习环境](https://mydev.csdn.net/product/pod/new?image=cimg-centos7-skilltreemysql&connect=auto&create=auto&utm_source=skill){target="_blank"}。
* `show databases;` 列出所有数据库
* `show tables;` 列出所有表
## 答案
```sql
create table orders (
id int primary key auto_increment,
item_id int,
amount int,
unit_price decimal(12, 4),
price decimal(12, 4),
ts timestamp default now()
);
```
## 选项
### A
```sql
create table orders (
id int primary key auto_increment,
item_id int,
amount int,
unit_price decimal(12, 4),
price decimal(12, 4),
ts varchar(16) default now()
);
```
### B
```sql
create table orders (
id int primary key auto_increment,
item_id int,
amount int,
unit_price decimal(12, 4),
price decimal(12, 4),
ts varchar(16) format 'yyyy-mm-dd'
);
```
### C
```sql
create table orders (
id int primary key auto_increment,
item_id int,
amount int,
unit_price decimal(12, 4),
price decimal(12, 4),
ts date default now()
);
```
### D
```sql
create table orders (
id int primary key auto_increment,
item_id int,
amount int,
unit_price decimal(12, 4),
price decimal(12, 4),
ts datetime default now()
);
```