数据库系统原理教程

部分实例代码(注意使用关系数据库标准语言SQL 实现代码) create database student

use student

create table student

(

sno char(10) primary key,

sname char(10),

sageint,

ssex char(2)check(ssex in ('男',' 女')),

sdept char(2)

)

create table course

(cno char(10),

cname char(20),

ccreditsmallint

primary key(cno),

teacher char(10)

)

create table sc

(sno char(10) references student(sno),

cno char(10),

gradeint,

primary key(cno,sno),

foreign key(cno) references course(cno)

)

insert

into student

values

(95001,'李勇',' 男',20,'CS',1996);

insert into student values

(95002,'刘晨',' 女',20,'IS',1996);

insert into student values

(95003,'王名',' 女',18,'MA',1996);

insert into student values

(95004,'张立',' 男',19,'IS',1996);

alter table course

drop column teacher

insert into course values (1,'数据库',4);

insert into course values (2,'数学',2);

insert into course values (3,'信息系统',4);

insert into sc values (95001,1);

insert into sc values (95001,2);

insert into sc values (95001,3);

insert into sc values (95002,2);

insert into sc values (95002,3);

select *

from student;

select *

from course;

select *

fromsc;

selectstudent.sno,sname,ssex,cno

fromstudent,sc

wherestudent.sno=sc.sno;

create unique index sc grade on sc(grade desc,snoasc); drop index sc.scgrade;

alter table student

alter column sage smallint;

create database spj

usespj

create table s

(

sno char(10) primary key,

sname char(10),

city char(10)

)

create table p

(

pno char(10) primary key,

pname char(10),

color char(3) check(color in('红',' 绿',' 蓝')), weight char(10)

)

create table j

(

jno char(10) primary key,

jname char(10),

city char (10)

)

create table spj

(

sno char(10) references s(sno), pno char(10),

jno char(10),

qtyint,

primary key (sno,pno,jno),

foreign key (pno) references p(pno), foreign key (jno) references j(jno) )

alter table spj add orderdatedatetime;

create table s1

(

sno char(10),

sname char(10),

city char(10)

)

create clustered index s1sno on s1(sno);

insert intoselect *

fromspj;

selectsno,sname

from student

wheresno=95001;

部分实例代码(注意使用关系数据库标准语言SQL 实现代码) create database student

use student

create table student

(

sno char(10) primary key,

sname char(10),

sageint,

ssex char(2)check(ssex in ('男',' 女')),

sdept char(2)

)

create table course

(cno char(10),

cname char(20),

ccreditsmallint

primary key(cno),

teacher char(10)

)

create table sc

(sno char(10) references student(sno),

cno char(10),

gradeint,

primary key(cno,sno),

foreign key(cno) references course(cno)

)

insert

into student

values

(95001,'李勇',' 男',20,'CS',1996);

insert into student values

(95002,'刘晨',' 女',20,'IS',1996);

insert into student values

(95003,'王名',' 女',18,'MA',1996);

insert into student values

(95004,'张立',' 男',19,'IS',1996);

alter table course

drop column teacher

insert into course values (1,'数据库',4);

insert into course values (2,'数学',2);

insert into course values (3,'信息系统',4);

insert into sc values (95001,1);

insert into sc values (95001,2);

insert into sc values (95001,3);

insert into sc values (95002,2);

insert into sc values (95002,3);

select *

from student;

select *

from course;

select *

fromsc;

selectstudent.sno,sname,ssex,cno

fromstudent,sc

wherestudent.sno=sc.sno;

create unique index sc grade on sc(grade desc,snoasc); drop index sc.scgrade;

alter table student

alter column sage smallint;

create database spj

usespj

create table s

(

sno char(10) primary key,

sname char(10),

city char(10)

)

create table p

(

pno char(10) primary key,

pname char(10),

color char(3) check(color in('红',' 绿',' 蓝')), weight char(10)

)

create table j

(

jno char(10) primary key,

jname char(10),

city char (10)

)

create table spj

(

sno char(10) references s(sno), pno char(10),

jno char(10),

qtyint,

primary key (sno,pno,jno),

foreign key (pno) references p(pno), foreign key (jno) references j(jno) )

alter table spj add orderdatedatetime;

create table s1

(

sno char(10),

sname char(10),

city char(10)

)

create clustered index s1sno on s1(sno);

insert intoselect *

fromspj;

selectsno,sname

from student

wheresno=95001;


相关内容

  • 专业课本名称
  • 环政: 化工安全工程概论 锅炉压力容器安全 事故调查与分析技术 工业防毒技术 职业卫生与防护 GPS 测量原理 建筑安全技术与管理 通风安全学 通风工程. 矿井瓦斯防治 安全工程专业英语 安全经济学 安全工程学火灾与爆炸灾害 安全人机工程学 安全系统工程 水质工程学(上下册) 建筑给水排水工程 给水 ...

  • 软件设计师考试经验
  • "软件设计师"考试经验谈 Posted on 2008-10-22 09:55 龙怀玉 阅读(694) 评论(1) 编辑 收藏 第一部分,关于题型 CASL:这是每年必考的一个试型, 在下午试题中最近几年都是一个题, 今年不会有什么变化.依然为一个题,5个空, 每空3分. C/C ...

  • 支撑材料目录
  • 支撑材料目录 附件一.编写的主要教材情况 1.<C 语言程序设计教程(第二版)>封面与扉页 2.<C 语言程序设计教程习题与上机指导(第二版)>封面与扉页 3.<计算机应用基础(第五版)>封面与扉页 4.<计算机应用基础习题与上机指导(第五版)>封面与 ...

  • 2017年软考网络管理员什么教程比较好呢!
  • 2017年软考网络管理员什么教程比较好呢! 2017年软考网络管理员什么教程比较好呢!下面是希赛小编为大家推荐的2017年软考网络管理员教程,希望能帮助学友们. <网络管理员教程> <网络管理员教程(第3版修订版全国计算机技术与软件专业技术资格水平考试指定用书) >(严体华. ...

  • [财务软件实用教程](通10.2版用)教案
  • 教学大纲 课程名称 财务软件应用 专 业执 笔 人 系 部 教 研 室 编制时间 课 程 内 容 及 要 求 第1章 会计信息系统概述 教学目的与要求: 本章对会计信息系统的基本概念和会计信息系统的发展情况做一概括的介绍,并重点介绍会计信息系统的管理和会计信息系统建设的方法.目的是使学员了解会计信息 ...

  • 数据库系统原理与设计(第二版)实验教程实验二
  • 1.select a.employeeNo,a.employeeName,a.hireDate from Employee a,Employee b where a.employeeNo!=b.employeeNo and a.employeeName!=b.employeeName and a.h ...

  • 计算机培训计划
  • 篇一:计算机培训教学计划 计算机培训教学计划 一.培训概述 1.培训内容 计算机办公软件应用是从事办公室文员.文秘等办公室资料文档整理工作.通过培训,使培训对象熟练掌握应用键盘输入中英文,掌握windows 操作系统的基础知识和基本技能.全面掌握office 2003软件的操作技能. 2.培训等级: ...

  • 广州中医药大学
  • 广州中医药大学 2005年招收非医学专业本科毕业生 攻读中医学硕博连读研究生招生简章 为适应新世纪发展的需要,提高中医学理论研究水平,促进学术进步,加速中医药现代化的步伐,探索培养中医学高层次复合型人才的新模式.新途径,根据国家教育部.国家中医药管理局的要求,2005年,广州中医药大学继续招收非医学 ...

  • 全国高等教育自学考试课程代码及选用教材
  • 全国高等教育自学考试课程代码及选用教材 课码 00009 课程名称 教材名称 教材主编 教材出版社 卫兴华等 经济科学出版社2004年版 高等教育出版社1999年版 高等教育出版社1999年版 机械工业出版社2005年版 武汉大学出版社2004年版 北京大学出版社2006年版 北京大学出版社2006 ...