?? db.txt
字號(hào):
創(chuàng)建product表create table product(id int primary key,pname varchar(20) not null, description varchar(64),price double(8,2) not null);創(chuàng)建user表create table user(id int primary key,userName varchar(20) not null unique, password varchar(20) not null,address varchar(256),postCode varchar(10), email varchar(32),homePhone varchar(32), cellPhone varchar(32),officePhone varchar(32));創(chuàng)建item表create table item(id int primary key, amount int , product_id int not null references product(id), order_id int not null references t_order(id));創(chuàng)建order表create table t_order(id int primary key, cost double(10,2), user_id int not null references user(id) );往表product中插入數(shù)據(jù)insert into product(id,pname,description,price) values(1,'pen','pen',5.00);insert into product(id,pname,description,price) values(2,'pencil','pencil',2.00);insert into product(id,pname,description,price) values(3,'rubber','rubber',1.00);insert into product(id,pname,description,price) values(4,'notebook','notebook',15.00);insert into product(id,pname,description,price) values(5,'gluewater','gluewater',10.00);insert into product(id,pname,description,price) values(6,'pencilcase','pencilcase',8.00);insert into product(id,pname,description,price) values(7,'bellpen','bellpen',12.00);insert into product(id,pname,description,price) values(8,'colorpen','colorpen',20.00);查看所有商品select id,pname,description,price from product;根據(jù)用戶名和密碼查找用戶查看所有的用戶select id,userName,password,address,postCode,email,homePhone,cellPhone,officePhone from user where 1=1;往表user中插入數(shù)據(jù)insert into user(id,userName,password,address,postCode,email,homePhone,cellPhone,officePhone) values(1,'tom','11','taiyuan','003201','tom@sina.com','88886666','88886666','88886666');更新用戶信息update user set 往表item中插入數(shù)據(jù)insert into item(id,amount,product_id,order_id) values(1);往表t_order中插入數(shù)據(jù)insert into t_order(id,user_id,cost) values();查詢用戶id為3的用戶的所有定單,商品,商品數(shù)量,總金額 select distinct p.pname,i.amount,o.oid,o.cost from product p,item i,t_order o where i.id in( select id from item where order_id in( select id from t_order where user_id=3)) and i.product_id=p.id and i.order_id=o.id
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -