数据库基础语句
###创建商品表
CREATE TABLE `item`(
`id` INT(20) NOT NULL AUTO_INCREMENT COMMENT'商品主键',
`title` VARCHAR(50) NOT NULL COMMENT '商品标题',
`price` VARCHAR(50) NOT NULL COMMENT '商品价格,单位分',
`num` INT(50) NOT NULL DEFAULT(0) COMMENT '商品库存',
PRIMARY KEY(id)
)ENGINE=INNODB CHARSET=utf8 COMMENT '商品表';
###创建订单表
CREATE TABLE `t_order1`(
`id` INT(20) NOT NULL AUTO_INCREMENT COMMENT'订单主键',
`price` DOUBLE(10,2) NOT NULL COMMENT'商品价格',
PRIMARY KEY(id)
)COMMENT '订单表';
###插入
INSERT INTO `item` VALUES(DEFAULT,'鸡蛋','2','1000');
INSERT INTO `item` VALUES(DEFAULT,'蛋糕','2','1000');
INSERT INTO `item` VALUES(DEFAULT,'苹果','2','1000');
INSERT INTO `item` VALUES(DEFAULT,'奶茶','6','600'),(DEFAULT,'牛奶','4','300');
###更新
UPDATE `item` SET `price`='6' WHERE `id`=3;
###删除
DELETE FROM`item` WHERE `id`=6;
###查找
SELECT * FROM`item`;
###单个查找
SELECT * FROM`item` WHERE`id`=3;
###清空
TRUNCATE`t_order1`;