create table CUSTOMERS
--客户表
(
cid varchar2(10) primary key, --客户编号
cname varchar2(10), --名称
city varchar2(20), --所在城市
discnt number(10,2) --折扣
)
insert into CUSTOMERS values ('c001','TipTop','Duluth',10.00)
insert into CUSTOMERS values ('c002','Basics','Dallas',12.00)
insert into CUSTOMERS values ('c003','Allied','Dallas',8.00)
insert into CUSTOMERS values ('c004','ACME','Duluth',8.00)
insert into CUSTOMERS values ('c006','ACME','Kyoto',0.00)
create table PRODUCTS --产品表
(
pid varchar2(10)primary key, --产品编号
pname varchar2(10), --名称
city varchar2(20), --产地
quantity varchar2(10), --库存量
price number(10,2) --单价
)
insert into PRODUCTS values ('p01','comb','Dallas','111400',0.50)
insert into PRODUCTS values ('p02','brush','Newark','203000',0.50)
insert into PRODUCTS values ('p03','razor','Duluth','150600',1.00)
insert into PRODUCTS values ('p04','pen','Duluth','125300',1.00)
insert into PRODUCTS values ('p05','pencil','Dallas','221400',1.00)
insert into PRODUCTS values ('p06','folder','Dallas','123100',2.00)
insert into PRODUCTS values ('p07','case','Newark','100500',1.00)
create table AGENTS
--代理商
(
aid varchar2(4) primary key, --编号
aname varchar2(10), --名称
city varchar2(10), --所在城市
percent number(10,4) --佣金百分比
)
insert into AGENTS values('a01','Smith','New York',6)
insert into AGENTS values('a02','Jones','Newark',6)
insert into AGENTS values('a03','Brown','Tokyo',7)
insert into AGENTS values('a04','Gray','New York',6)
insert into AGENTS values('a05','Otasi','Duluth',5)
insert into AGENTS values('a06','Smith','Dallas',5)
create table ORDERS --订单表
(
ordno varchar2(4), --订单号
cid varchar2(10), --客户编号
aid varchar2(4), --代理商编号
pid varchar2(10), --产品编号
qty number(5), --数量
dollars number(10,2) --总金额
)
insert
into
ORDERS values
(
'1011'
,
'c001'
,
'a01'
,
'p01'
,
1000
,
450.00
)
insert into ORDERS values('1012', 'c001','a01','p01',1000,450.00)
insert into ORDERS values('1019', 'c001','a02','p02',400,180.00)
insert into ORDERS values('1017', 'c001','a06','p03',600,540.00)
insert into ORDERS values('1018', 'c001','a03','p04',600,540.00)
insert into ORDERS values('1023', 'c001','a04','p05',500,450.00)
insert into ORDERS values('1022', 'c001','a05','p06',400,720.00)
insert into ORDERS values('1025', 'c001','a05','p07',800,720.00)
insert into ORDERS values('1013', 'c002','a03','p03',1000,880.00)
insert into ORDERS values('1026', 'c002','a05','p03',800,704.00)
insert into ORDERS values('1015', 'c003','a03','p05',1200,1104.00)
insert into ORDERS values('1014', 'c003','a03','p05',1200,1104.00)
insert into ORDERS values('1021', 'c004','a06','p01',1000,460.00)
insert into ORDERS values('1016', 'c006','a01','p01',1000,500.00)
insert into ORDERS values('1020', 'c006','a03','p07',600,600.00)
insert into ORDERS values('1024', 'c006','a06','p01',800,400.00)