西南交通大学数据库原理实验设计探究.doc

  1. 1、本文档共25页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
第  PAGE 25 页 共  NUMPAGES 25 页 2014-2015学年第一学期 《数据库原理》 课程实验报告 学 号: 学生姓名: 徐玉松 班 级: 软件工程2012 教 师: 陶宏才 辅导老师: 王泽洲 赵红芳 2014年12月 实验一:表及约束的创建 1.1 实验目的与内容 目的:创建数据表、添加和删除列、实现所创建表的完整性约束。 内容:11-2、11-26~33。 注:实验内容编号均取自《数据库原理及设计(第2版)》第11章的实验!即:实验内容以第2版教材为准! 报告:以11-31作为实验一的报告。 1.2 实验代码及结果 1.2.1 实验代码 create table perso --创建新表 ( P_no char(6) primary key, P_name varchar(10) not null, Sex char(2) not null, Birthdate datetime null, Date_hired datetime not null, Deptname varchar(10) not null DEFAULT培训部, P_boss char(6) null, constraint birth_hire_check --为约束创建一个名称 check (BirthdateDate_hired) ) create table custome( Cust_no char(6) primary key, Cust_name varchar(10) not null, Sex char(2) not null, BirthDate datetime null, City varchar(10) null, Discount Dec(4,2) not null, constraint Discount_check --检查约束 的名称 check (Discount=0.5 and Discount=1 ) --检查约束 ) --create rule d as @state between 0 and 1 --创建规则 --sp_bindrule d,customeDiscount --这种方法也可以给Discount约束 绑定规则 create table orderdetai( Order_no char(6) primary key, constraint Order_no_constraint CHeck(Order_no LIKE[A-Z][A-Z][0-9][0-9][0-9][0-9]), Cust_no char(6) not null, P_no char(6) not null, Order_total int not null, Order_date datetime not null, constraint persocontr FOREIGN KEY(P_no) --定义外键为P_no REFERENCES persoP_no) --外键参照主表perso的P_no on delete NO Action --参照定义为不许删除 on update cascade, --定义为可随着主表跟新 constraint cusrtomecontr foreign key (Cust_no) REFERENCES customeCust_no) --参考 on delete NO Action on update cascade ) create table salar( P_no Char(6) primary key, Base Dec(8,2) not null, Bonus Dec(8,2) not null, Fact AS Base+Bonus , constraint person2_c

文档评论(0)

希望之星 + 关注
实名认证
内容提供者

我是一名原创力文库的爱好者!从事自由职业!

1亿VIP精品文档

相关文档