实验用数据库内容

2018-06-18 01:24:00来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

 1 create table student(sno char(9) primary key,sname char(20) unique,ssex char(2),sage smallint, sdept char(20));
 2 create table course(cno char(4) primary key,cname char(40) not null,cpno char(4),ccredit smallint,foreign key(cpno) references course(cno));
 3 create table sc(sno char(9),cno char(4),grade smallint,primary key(sno,cno),foreign key(sno) references student(sno),foreign key(cno) references course(cno));
 4 
 5 insert into course values('1','数据库','5','4.0');
 6 insert into course values('2','高等数学','NULL','2.0');
 7 insert into course values('3','信息系统','1','4.0');
 8 insert into course values('4','操作系统','6','3.0');
 9 insert into course values('5','数据结构','7','4.0');
10 insert into course values('6','数据处理','NULL','2.0');
11 insert into course values('7','C语言','6','4.0');
12 
13 insert into sc values('95001','1','92.0');
14 insert into sc values('95001','2','85.0');
15 insert into sc values('95001','3','88.0');
16 insert into sc values('95002','2','90.0');
17 insert into sc values('95002','3','80.0');
18 insert into sc values('95004','2','65.0');
19 insert into sc values('95004','3',NULL);
20 insert into sc values('95004','4',NULL);
21 insert into sc values('95005','2','84.0');
22 insert into sc values('95005','4',NULL);
23 insert into sc values('96001','1','87.0');
24 insert into sc values('96001','2','80.0');
25 insert into sc values('96001','3','90.0');
26 insert into sc values('96001','4','95.0');
27 insert into sc values('96001','5',NULL);
28 insert into sc values('96001','6',NULL);
29 insert into sc values('96001','7','86.0');
30 insert into sc values('97001','4',NULL);
31 insert into sc values('97001','5',NULL);
32 
33 create table dept(deptno numeric(2) primary key,dname varchar(14) not null,loc varchar(13));
34 
35 insert into dept values(10,'ACCOUNTING','NEWYORK');
36 insert into dept values(20,'RESEARCH','DALLAS');
37 insert into dept values(30,'SALES','CHICAGO');
38 insert into dept values(40,'OPERATIONS','BOSTON');
39 (^['0-9]{2,}[^;]+)
40 
41 create table emp(empno numeric(4) primary key,ename varchar(10) not null,job varchar(9),
42 mgr numeric(4),hiredate date,sal numeric(7,2) check (sal>500 and sal<100000),comm numeric(7,2),
43 deptno numeric(2),foreign key(mgr) references emp(empno),foreign key(deptno) references dept(deptno));
44 
45 insert into emp values(7369,'SMITH','CLERK',7902,'1980-12-17',800,null,20);
46 insert into emp values(7499,'ALLEN','SALESMAN',7698,'1981-02-20',1600,300,30);
47 insert into emp values(7521,'WARD','SALESMAN',7698,'1981-02-22',1250,500,30);
48 insert into emp values(7566,'JONES','MANAGER',7839,'1981-04-02',2975,null,20);
49 insert into emp values(7654,'MARTIN','SALESMAN',7698,'1981-09-28',1250,1400,30);
50 insert into emp values(7698,'BLAKE','MANAGER',7839,'1981-05-01',2850,null,30);
51 insert into emp values(7782,'CLARK','MANAGER',7839,'1981-06-09',2450,null,10);
52 insert into emp values(7788,'SCOTT','ANALYST',7566,'1987-04-19',3000,null,20);
53 insert into emp values(7839,'KING','PRESIDENT',null,'1981-11-17',5000,null,10);
54 insert into emp values(7844,'TURNER','SALESMAN',7698,'1981-09-08',1500,0,30);
55 insert into emp values(7876,'ADAMS','CLERK',7788,'1987-05-23',1100,null,20);
56 insert into emp values(7900,'JAMES','CLERK',7698,'1981-12-03',950,null,30);
57 
58 create table salgrade(grade numeric,losal numeric,hisal numeric);
59 
60 insert into salgrade values(1,700,1200);
61 insert into salgrade values(2,1201,1400);
62 insert into salgrade values(3,1401,2000);
63 insert into salgrade values(4,2001,3000);
64 insert into salgrade values(5,3001,9999);
65 insert into salgrade values(6,10000,100000);

2018-04-30  21:34:29

 1 create table persons(id_p int(2) primary key, lastname varchar(20) not null,firstname varchar(20) not null,address varchar(30),city varchar(20));
 2 insert into persons values(1,'Adams','John','Oxford Street','London');
 3 insert into persons values(2,'Bush','George','Fifth Avenue','New York');
 4 insert into persons values(3,'Carter','Thomas','Changan Street','Beijing');
 5 
 6 create table orders(id_o int(2) primary key, orderNo varchar(10),id_p int (2), foreign key(id_p) references persons(id_p));
 7 insert into orders values(1,'77895',3);
 8 insert into orders values(2,'44678',3);
 9 insert into orders values(3,'22456',1);
10 insert into orders values(4,'24562',1);
11 insert into orders values(5,'34764',65);

2018-05-05 18:41:35

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:mysql/mariadb学习记录——创建删除数据库、表的基本命令

下一篇:安装及配置mysql-5.7.21-winx64