drop database if exists ssm;
create database ssm;
use ssm;
##创建图书表
create table t_book(
`id` int(11) primary key auto_increment, ## 主键
`name` varchar(50) not null, ## 书名
`author` varchar(50) not null, ## 作者
`price` decimal(11,2) not null, ## 价格
`sales` int(11) not null, ## 销量
`stock` int(11) ## 库存
);
## 插入初始化测试数据
insert into t_book(`id` , `name` , `author` , `price` , `sales` , `stock`)
values(null , '平凡的世界' , '路遥' , 80 , 9999 , 9 );
insert into t_book(`id` , `name` , `author` , `price` , `sales` , `stock`)
values(null , '如何阅读一本书' , '莫提默·J. 艾德勒' , 78.5 , 6 , 13 );
insert into t_book(`id` , `name` , `author` , `price` , `sales` , `stock`)
values(null , '月亮与六便士' , '毛姆' , 68, 99999 , 52 );
insert into t_book(`id` , `name` , `author` , `price` , `sales` , `stock`)
values(null , '白夜行' , '东野圭吾' , 16, 1000 , 50 );
insert into t_book(`id` , `name` , `author` , `price` , `sales` , `stock`)
values(null , 'Java编程思想' , '埃克尔' , 45.5 , 14 , 95 );
insert into t_book(`id` , `name` , `author` , `price` , `sales` , `stock`)
values(null , '三体' , '刘慈欣' , 9.9, 12 , 53 );
insert into t_book(`id` , `name` , `author` , `price` , `sales` , `stock`)
values(null , '龙族' , '江南' , 66.5, 125 , 535 );
insert into t_book(`id` , `name` , `author` , `price` , `sales` , `stock`)
values(null , '简爱' , '夏洛蒂·勃朗特' , 99.5 , 47 , 36 );
insert into t_book(`id` , `name` , `author` , `price` , `sales` , `stock`)
values(null , '大话设计模式' , '吴强' , 89.15 , 20 , 10 );
insert into t_book(`id` , `name` , `author` , `price` , `sales` , `stock`)
values(null , '人月神话' , '布鲁克斯' , 88.15 , 20 , 80 );
## 查看表内容
select id,name,author,price,sales,stock from t_book;