数据库实验报告
实验二 交互式 SQL 语言
实验报告
《数据库系统概论》实验报告
题目:交互式SQL
姓名
刘忠梅
日期
2012-6-19
实验环境:操作系统:Windows 7 ; 数据库管理系统:MS SQL Server 2008
实验内容与完成情况:
数据定义:
表的创建、修改及删除
(1)学生表:Student(Sno,Sname,Sex,Sage,Sdept)。Student由学号(Sno)、姓名(Sname)、性别(Sex)、年龄(Sage)、所在系(Sdept)五个属性组成,其中Sno为主键。
create table Student
(Snochar(9)primary key not null,
Snamechar(20) unique not null,
Ssexchar(2) not null,
Sage smallint not null,
Sdeptchar(20) not null)
Insertinto Student (Sno,Sname,Ssex,Sage,Sdept)
values('','李勇','男',20,'CS')
insert into Student (Sno,Sname,Ssex,Sage,Sdept)
values('','刘晨','女',19,'CS')
insert into Student (Sno,Sname,Ssex,Sage,Sdept)
values('','王敏','女',18,'MA')
insert into Student (Sno,Sname,Ssex,Sage,Sdept)
values('','张立','男',19,'IS')
(2)课程表:Course(Cno,Cname,Cpno,Ccredit)
Course课程号(Cno)、课程名(Cname)、先行课的课程号(Cpno)、学分(Ccredit)四个属性组成,其中Cno为主键。其中Cpno参考了本表的Cno字段的值,Cno为主键
create table course
( cno char (40) primary key not null,
cname char(4)not null,
ccreditsmallint not null
foreign key(Cpon)references course(Cno))
insert into Course values('1','数据库','5',4)
insert into Course values('2','数学','',2)
insert into Course values('3','信息系统','1',4)
insert into Course values('4','操作系统','6',3)
insert into Course values('5','数据结构','7',4)
3基本表的修改:
a)向Student表增加“入学时间”列,期数据类型为日期型
b)将年龄的数据类型由字符型改为整型
c)增加课程名称必须取唯一值的约束条件
alter table studebt add s_
数据库上机报告 来自淘豆网m.daumloan.com转载请标明出处.