数据库原理实验报告分?- 百度文库 ر

(13) ʹUNIONѯ

ҪSQLֱѯиߡмְƵְϲ

select P_name from person where Prof='м' union

select P_name from person where Prof='߼'

ʵܽ

1ڲѯУ漰жУӦô á.ָĸеɲ

2ѯûΪײѯʲô壬

𣺿á ķʽи

3.дSQLIJѯ䣬DBMSִеȺ˳

ִfrom䣬ִwhereִgroup byִзhavingıʽselectеݡ

ʵ

һʵĿ

Ե壻 ݱݷ ݿָ

ʵ

1ѧʵʹã

CREATE RULE sex_rule AS @sex IN('','Ů')--

Sp_bindrule 'sex_rule','person.sex'--󶨹--ѽ󶨵С

Sp_unbindrule 'person.sex'--󶨡 DROP RULE sex_rule--ɾ

2ݿеݽи¡ɾǷɹɹݿʧܵԭ

A. Զв롢¼ɾʱӰ졣 Ҫ

deptвһ(0004з)ǷӰӱ

insert

into dept (Deptno,Dname) values ('0004','з')

//Ӱ죬ɹΪ²һݣԶԴӱӰ deptеIJź0003Ϊ0006ǷӰӱ

update dept set Deptno='0006' where Deptno='0003'

//Ӱ죬ɹpersonвźԣԻܵǣƣȸıdeptеݡ

ʾUPDATE REFERENCE Լ\ͻóͻݿ\

\ ֹ

ɾdeptвźΪ0001ԱݣǷӰӱ

delete from dept

where Deptno='0001'

//Ӱ죬ɹpersonвźԣԻܵǣƣȸıdeptеݡ

ʾDELETE REFERENCE Լ\ͻóͻݿ\

\ ֹ

B. ԶԴӱв롢¼ɾʱӰ졣 Ҫ

personвһ(000012ȫ񡯣С1980-7-170005)ǷΥԡ

insert

into person (P_no,P_name,Sex,BirthDate,Prof,Deptno) values ('000012','ȫ','',1980-7-17,'','0005')

//Ӱ죬ɹdeptвźԣΪ룬Իܵǣƣȴdept

ʾINSERT FOREIGN KEY Լ\ͻóͻݿ\

\ ֹ

ڽpersonйΪ000002ԱڲŸΪ0005ǷΥԡ

update person set Deptno='0005' where P_no='000002'

//Ӱ죬ɹdeptвźԣΪ룬Իܵǣƣȴdept

ʾUPDATE FOREIGN KEY Լ\ͻóͻݿ\

\ ֹ

ɾpersonйΪ000005ԱݣǷΥԡ

delete from person

where P_no='000005'

//Ӱ죬ɹdeptвźԣΪ룬Իܵǣƣȴdept

ʾDELETE REFERENCE Լ\ͻóͻݿ\

\ ֹ

3ݱݺͻָ

ʵܽ

1ݿ԰ЩԼSQLֱЩؼʵֵģ

ԣʵԿͨ˲Լ?checkԼ?Լ

?foreign keyԼ?ĬֵԼ?defaultԼ?ǿԼ?not nullԼ?ʵʩ

ʵԣеIdentityԡԼ?primany keyԼ?ΩһԼ?uniqueԼ?ʵ֡

ԣͨ?Լ????洢?ʵʩ 2ݿⱸʲôô

ʧݶʧɻص֮ǰ״̬