show databases 查看所有库
create database shop 创建库 shop
use shop进入shop库
create table orders(创建orders 表
id int primary key auto_increment not null,主键自增
sname varchar(40) default '',商品名
create_time varchar(20),上架时间
number int,商品数量
price decimal(5,2),商品价格
order_id int订单id
)
select * from orders
insert into orders VALUES(0,"方便面","2010-11-10",10,111.00,1)单条插入
INSERT into orders values (0,"洗衣粉","2012-11-10",30,2.00,1),多条插入
(0,"泡泡糖","2014-11-10",40,2.00,2),
(0,"巧克力","2013-11-10",50,6.00,2),
(0,"可爱多","2015-11-10",23,3.50,2),
(0,"面包","2008-11-10",3,3.00,3)
update orders set sname = "干脆面" where sname = "方便面"修改内容(方便面为干脆面)
delete from orders where sname = "面包"删除面包
select max(number) from orders where order_id=1查询order_id为1的最大值
select * from orders where sname like '洗%' 根据洗字开头进行查询
select * from orders where create_time between "2010-11-10" and "2015-11-10" 查询xxx和xxx之间的内容