




如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
(精品word)数据库系统概论实验二 (精品word)数据库系统概论实验二 (精品word)数据库系统概论实验二 实验内容 一、数据定义 (一)基本表操作 1。建立基本表 在数据库test中建立3章基本表:Student、Course和SC (1).创建学生表Student(Sno,Sname,Ssex,deptno) (2)创建课程表Course(cno,cname,tno,credit) (3).创建学生选课表SC(sno,cno,grade), (4)。创建教师表teacher(tno,tname,deptno) (5).创建系表dept(deptno,dname) Sql语言如下: createtablestudent (snointprimarykey, snamechar(8)unique, ssexchar(2), deptnoint ); createtablecourse (cnointprimarykey, cnamechar(20)notNULL, tnoint, creditint, foreignkey(tno)referencesteacher(tno) ); createtablesc (snoint, cnoint, gradeint, primarykey(sno,cno), foreignkey(sno)referencesstudent(sno), foreignkey(cno)referencescourse(cno) ); createtableteacher (tnointprimarykey, tnamechar(8)notNULL, deptnoint ); createtabledept ( deptnointprimarykey, dnamechar(20)notNULL ); 2.修改基本表 在student表中加入属性年龄age(int型) Sql语言如下: altertablestudentaddsageint; 3.删除基本表(不作) 注意:要在后面的所有操作结束后删除基本表 (1)删除student表 (2)在所有操作结束后删除Course表 (3)在所有操作结束后删除SC表 (4)在所有操作结束后删除Teacher表 (5)在所有操作结束后删除Dept表 Sql语言如下: Droptablestudent; Droptablecourse; Droptableteacher; Droptabledept; Droptablesc; (二)建立索引 1。建立索引 (1)在student表上建立关于属性的sno的唯一索引stusno。 (2)在Course表上建立关于cno的唯一索引coucno。 2.删除索引 (1)删除student表上的索引stutno。 (2)删除course表上的索引coucno。 Sql语言如下: createuniqueindexstusnoonstudent(sno); createuniqueindexcoucnooncourse(cno); dropindexstusnoonstudent dropindexcoucnooncourse (三)视图操作 1.建立视图 在插入数据的student基本表上为计算机学生的记录建立一个视图cs_student。 2.删除视图 在操作结束后,删除视图cs_student Sql语言如下: createviewcs_student as select*fromStudent wheredeptnoin (selectdeptnofromdept wheredept.deptno=Student.deptno anddeptname='计算机科学与技术’); dropviewcs_student 二、数据操作 (一)更新数据 Sql语言如下: -—向Dept表中插入下列数据: insertinto dept(deptno,deptname) values(10,’计算机科学与技术’); insertinto dept(deptno,deptname) values(20,’信息’); —-向teacher表中插入下列数据: insertinto teacher(tno,tname,deptno) values(101,'张星',10); insertinto teacher(tno,tname,deptno) values(102,'李珊’,10); insertinto teacher(tno,tname,deptno) values(103,’赵应天’,10); insertinto teacher(tno,tnam

17****21
实名认证
内容提供者


最近下载