想找个范例的数据库原来真不是简单。呵呵
原书本上的数据库只是个标准,不是实现的版本。
在网上艰辛地找到了这个表格之后与发现自已用的Mysql字段的类型不符。
于是做了改动。下面的Sql文件可以直接导入Mysql了。
有了这个东东。可以节省很多输入的时间。学习更方便了。
--study.sql文件如下:
create datebase study;
use study
--表employee_tbl结构
create table employee_tbl
(emp_id varchar(9) not null,
last_name varchar(15) not null,
first_name varchar(15) not null,
middle_name varchar(15),
address varchar(30) not null,
city varchar(15) not null,
state char(2) not null,
zip numeric(5) not null,
phone char(10),
pager char(10),
constraint emp_pk primary key(emp_id) );
--表employee_pay_tbl结构
create table employee_pay_tbl
(emp_id varchar(9) not null,
position varchar(15) not null,
date_hire date,
pay_rate numeric(4,2),
date_last_raise date,
salary numeric(8,2),
bonus numeric(6,2),
constraint emp_fk foreign key(emp_id) references employee_tbl(emp_id) );
--表customer_tbl结构
create table customer_tbl
(cust_id varchar(10) not null primary key,
cust_name varchar(30) not null,
cust_address varchar(20) not null,
cust_city varchar(15) not null,
cust_state char(2) not null,
cust_zip numeric(5) not null,
cust_phone numeric(10),
cust_fax numeric(10) );
--表orders_tbl结构
create table orders_tbl
(ord_num varchar(10) not null primary key,
cust_id varchar(10) not null,
prod_id varchar(10) not null,
qty numeric(6) not null,
ord_date date );
--表products_tbl结构
create table products_tbl
(prod_id varchar(10) not null primary key,
prod_desc varchar(40) not null,
cost numeric(6,2) not null );
以下是各表的插入记录。
insert into employee_tbl values
('311549902','STEPHENS','TINA','DAWN','RR 3 BOX 17A','GREEN WOOD',
'IN','47890','3178784465',NULL) ;
insert into employee_tbl values
('442346889','PLEW','LINDA','CAROL','3301 REACON','INDIANAPO LIS',
'IN','46224','3172978990',NULL) ;
insert into employee_tbl values
('213764555','GLASS','BRANDON','SCOTT','1710 MAIN ST','WHITELAND',
'IN','47885','3178984321','3175709980') ;
insert into employee_tbl values
('313782439','GLASS','JACOB',NULL,'3789 WHITE RIVER BLVD',
'INDIANAPOLIS','IN','45734','3175457676','8887345678') ;
insert into employee_tbl values
('220984332','WALLACE','MARIAH',NULL,'7889 KEYSTONE AVE',
'INDIANAPOLIS','IN','48741','3173325986',NULL) ;
insert into employee_tbl values
('443679012','SPURGEON','TIFFANY',NULL,'5 GEORGE COURT',
'INDIANAPOLIS','IN','46234','317569007',NULL) ;
insert into employee_pay_tbl values
('311549902','MARKETING','1989-05-23',NULL,'1997-05-01','40000',NULL) ;
insert into employee_pay_tbl values
('442346889','TEAM LEADER','1990-06-17','14.75','1997-06-01',NULL,NULL) ;