您所在位置: 网站首页 / (精品word)数据库系统概论实验二.doc / 文档详情
(精品word)数据库系统概论实验二.doc 立即下载
2024-09-09
约3.6千字
约9页
0
32KB
举报 版权申诉
预览加载中,请您耐心等待几秒...

(精品word)数据库系统概论实验二.doc

(精品word)数据库系统概论实验二.doc

预览

免费试读已结束,剩余 4 页请下载文档后查看

5 金币

下载文档

如果您无法下载资料,请参考说明:

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
查看更多
单篇购买
VIP会员(1亿+VIP文档免费下)

扫码即表示接受《下载须知》

(精品word)数据库系统概论实验二

文档大小:32KB

限时特价:扫码查看

• 请登录后再进行扫码购买
• 使用微信/支付宝扫码注册及付费下载,详阅 用户协议 隐私政策
• 如已在其他页面进行付款,请刷新当前页面重试
• 付费购买成功后,此文档可永久免费下载
全场最划算
12个月
199.0
¥360.0
限时特惠
3个月
69.9
¥90.0
新人专享
1个月
19.9
¥30.0
24个月
398.0
¥720.0
6个月会员
139.9
¥180.0

6亿VIP文档任选,共次下载特权。

已优惠

微信/支付宝扫码完成支付,可开具发票

VIP尽享专属权益

VIP文档免费下载

赠送VIP文档免费下载次数

阅读免打扰

去除文档详情页间广告

专属身份标识

尊贵的VIP专属身份标识

高级客服

一对一高级客服服务

多端互通

电脑端/手机端权益通用