CREATE DATABASE test;
use test;
CREATE TABLE goods (
id INT PRIMARY KEY AUTO_INCREMENT COMMENT '商品编号',
type VARCHAR(30) NOT NULL COMMENT '商品类别',
name VARCHAR(30) UNIQUE COMMENT '商品名称',
price DECIMAL(7, 2) COMMENT '商品价格',
num INT DEFAULT 0 COMMENT '商品库存',
add_time DATETIME COMMENT '添加时间'
);
INSERT INTO goods(id, type, name, price, num, add_time)
VALUES(1,'书本','西游记',50.4,20,'2018-01-01 13:40:40'),
(2,'糖果','牛奶糖',7.5,200,'2018-02-02 13:40:40'),
(3,'糖果','水果糖',2.5,100,NULL),
(4,'衣服','连衣裙',800,NULL,'2018-04-04 13:40:40'),
(5,'饮品','可乐',3,70,'2018-05-05 13:40:40');
select aaa.id as '编号', aaa.name as '名称', aaa.type as '类别', aaa.add_time as '添加时间' from goods as aaa;