- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
创建主键、外键和唯一约束(Create primary, foreign, and unique constraints)
创建主键、外键和唯一约束(Create primary, foreign, and unique constraints)
Oracle creates primary, foreign, and unique constraints
Oracle. First create student information table studentinfo and student achievement table testinfo.
-- student information sheet
The CREATE TABLE studentInfo (
StuNo CHAR (10) NOT NULL,
StuName VARCHAR2 (20) NOT NULL,
StuSex NUMBER (1),
StuBirthday DATE DEFAULT SYSDATE,
StuAddress VARCHAR2 (20)
);
-- student achievement sheets
The CREATE TABLE testInfo (
StuNo CHAR (10) NOT NULL,
ClassNo CHAR (5) NOT NULL,
TestScore NUMBER (3, 1)
);
-- constraints: set the primary key
Alter table testinfo add constraint fk_1 foreign key (stuno);
-- constraints: set foreign keys
Alter table studentinfo add constraint pk_1 primary key (stuno);
-- constraints: set unique
Alter table testinfo add constraint uniq_1 unique (stuno, classno);
- insert test data
INSERT INTO STUDENTINFO VALUES ( 001 , ZHANGSAN, 1, 03 - January - 86, nanjing xuanwu district);
INSERT INTO STUDENTINFO VALUES ( 002 , LISI, 1, 05 - December - 86, nanjing xuanwu district);
INSERT INTO STUDENTINFO VALUES ( 003 , WANGWU, 0, 03-october - 85, the white lower area of nanjing city);
INSERT INTO STUDENTINFO VALUES ( 004 , ZHANGSAN, 1, 23 - October - 88, nanjing xiuguan district);
INSERT INTO STUDENTINFO VALUES ( 005 , SMITH, 0, 31-october-89, nanjing basalt);
INSERT INTO STUDENTINFO VALUES ( 006 , ALLEN, ALLEN, 25 - December - 86, nanjing qixia district);
INSERT INTO STUDENTINFO VALUES ( 007 , SCOTT, 1, 08 - November - 86, the pukou district of nanjing city);
INSERT INTO STUDENTINFO VALUES ( 008 , BRUCE LEE, 0, 03 - November - 80, yuhua district, nanjing);
INSERT INTO STUDENTINFO VALUES ( 009 , BRUCE LEE, 1, 09 - December - 87, nanjing liuhe district);
INSERT INTO STUDENTINFO VALUES ( 010 , ZHANGSAN, 1, 13 - November - 82, nanjing xuanwu district);
INSERT INTO TESTINFO VALUES ( 001 , 02, 90.5);
INSERT INTO TESTINFO VALUES ( 001 , 01, 80);
INSERT INTO TESTINFO VALUES ( 001 , 03, 60).
INSERT INTO TESTINFO VAL
您可能关注的文档
- 中考励志故事(An inspirational story).doc
- 中考总复习第二章(The central examination review chapter ii).doc
- 中考总复习第三章(The central examination review chapter three).doc
- 中考数学备考第一轮编排(The first round of the math test preparation).doc
- 中考物理复习(Physics review).doc
- 中考生字词(Chinese word).doc
- 中考考点_1(The middle entrance exam is _1).doc
- 中考考点(Tests the examination site).doc
- 中英日水果蔬菜_1(Chinese and English fruits and vegetables _1).doc
- 中山大学(Sun yat-sen university).doc
- 创业必须的心态(The mindset of starting a business).doc
- 创新作文(Creative composition).doc
- 创新研修课之子电路的可靠性设计论文(The reliability design thesis of the sub-circuit of innovation research course).doc
- 创新思维与创新人才的培养(The cultivation of innovative thinking and innovative talents).doc
- 初2物理上(First 2 physics).doc
- 初一科学(The first scientific).doc
- 初三化学复习资料 下(Primary 3 chemistry review data).doc
- 初三地理总复习资料(七年级上下册)(First three geographical review materials (upstream and upstream of seventh grade)).doc
- 初三物理完(Primary three physics).doc
- 初三物理(Grade physics).doc
文档评论(0)