数据库实验(一)
1、create table test1_teacher(
tid char(6) primary key,name varchar(10) not null,
sex char(2),age int, dname varchar(10) )
create index index_table1 on test1_teacher(name);
insert into test1_teacher values('100101','张老师','男',44,'计算机学
院');
insert into test1_teacher values('100102','李老师','女',45,'软件学院');
insert into test1_teacher values('100103','马老师','男',46,'计算机学
院');
2、create table test1_student(
sid char(12) primary key, name varchar(10) not null,sex
char(2),
age int, birthday date, dname varchar(10),class
varchar(10))
create index index_table2 on test1_student(name);
insert into test1_student values('200800020101','王欣','女',19,
to_date('19940202','yyyymmdd'),'计算机学
院','2010');
insert into test1_student values('200800020102','李华','女',20,
to_date('19950303','yyyymmdd'),'软件学
院','2009');
insert into test1_student values('200800020103','赵岩','男',18,
to_date('19960404','yyyymmdd'),'软件学
院','2009');
3 、 create table test1_course( cid char(6) primary key, name
varchar(10) not null,
fcid char(6),credit numeric(2,1) )
create index index_table3 on test1_course(name);
insert into test1_course values('300001','数据结构','',2);
insert into test1_course values('300002','数据库','300001',2.5);
insert into test1_course values('300003','操作系统','300001',4);
4、 create table test1_student_course(
sid char(12) , cid char(6) , score numeric(5,1), tid char(6),
primary key(sid,cid),
FOREIGN KEY (sid) REFERENCES test1_student(sid),
FOREIGN KEY (cid) REFERENCES test1_course(cid),
FOREIGN KEY (tid) REFERENCES test1_teacher(tid) )
insert into test1_student_course
values('200800020101','300001',91.5,'100101');
insert into test1_student_course