数据库创建表,插入数据练习
create table shangpin("商品名称" varchar2(30),
"商品种类" varchar2(30),
"商品单价" number(30)
)
insert into shangpin values('手机','电子产品',6600)
insert into shangpin values('苹果','水果',5)
insert into shangpin values('花椒','调料',1)
insert into shangpin values('牛肉','肉类',6600)
insert into shangpin values('薯片','零食',6600)
insert into shangpin values('拖把','生活用品',15)
insert into shangpin values('炒锅','厨具',50)
insert into shangpin values('短袖','服饰',90)
insert into shangpin values('皮鞋','鞋类',240)
select * from shangpin
--创建表
create table gouwucar("顾客" varchar2(30),
"购买商品" varchar2(30),
"购买数量" number(30)
)
--插入数据
insert into gouwucar values('tom','手机',1)
insert into gouwucar values('jick','苹果',10)
insert into gouwucar values('lili','拖把',1)
insert into gouwucar values('lilei','炒锅',1)
insert into gouwucar values('joce','短袖',3)
insert into gouwucar values('halen','皮鞋',2)
insert into gouwucar values('张三','null',null)
insert into gouwucar values('李四','null',null)
insert into gouwucar values('王五','薯片',5)
select * from gouwucar
--创建表
create table jiesuan("商品" varchar2(30),"数量" number(30),"总价" number(30))
--插入数据
insert into jiesuan values('手机',1,6600)
insert into jiesuan values('皮鞋',1,240)
insert into jiesuan values('炒锅',1,50)
insert into jiesuan values('短袖',1,15)
insert into jiesuan values('拖把',1,90)
insert into jiesuan values('花椒',1,1)
insert into jiesuan values('苹果',1,5)
insert into jiesuan values('薯片',1,6)
select * from jiesuan;
--select 顾客,购买商品,商品种类,商品单价,购买数量 from shangpin,gouwucar
--where shangpin.商品名称=gouwucar.购买商品
--关联表
select 顾客,购买商品,商品种类,商品单价,购买数量,总价 from shangpin,gouwucar,jiesuan
where (shangpin.商品名称=gouwucar.购买商品) and (gouwucar.购买商品=jiesuan.商品)