¡¶Êý¾Ý¿âÔ­Àí¼°Ó¦Óá·Óʵç¶þ°æ Ï°Ìâ²Î¿¼´ð°¸£¨×ÜÌ壩 ÏÂÔر¾ÎÄ

¡¤37¡¤ µÚ9Õ Êý¾Ý¿â±à³Ì

Ò»£® Ñ¡ÔñÌâ

1£®´´½¨´æ´¢¹ý³ÌµÄÓô¦Ö÷ÒªÊÇ

A£®Ìá¸ßÊý¾Ý²Ù×÷ЧÂÊ C£®ÊµÏÖ¸´ÔÓµÄÒµÎñ¹æÔò

A

B£®Î¬»¤Êý¾ÝµÄÒ»ÖÂÐÔ D£®ÔöÇ¿ÒýÓÃÍêÕûÐÔ

2£®ÏÂÁйØÓÚ´æ´¢¹ý³ÌµÄ˵·¨£¬ÕýÈ·µÄÊÇ A

A£®ÔÚ¶¨Òå´æ´¢¹ý³ÌµÄ´úÂëÖпÉÒÔ°üº¬Êý¾ÝµÄÔö¡¢É¾¡¢¸Ä¡¢²éÓï¾ä B£®Óû§¿ÉÒÔÏò´æ´¢¹ý³Ì´«µÝ²ÎÊý£¬µ«²»ÄÜÊä³ö´æ´¢¹ý³Ì²úÉúµÄ½á¹û C£®´æ´¢¹ý³ÌµÄÖ´ÐÐÊÇÔÚ¿Í»§¶ËÍê³ÉµÄ

D£®´æ´¢¹ý³ÌÊÇ´æ´¢ÔÚ¿Í»§¶ËµÄ¿ÉÖ´ÐдúÂë¶Î

3£®ÉèÒª¶¨ÒåÒ»¸ö°üº¬2¸öÊäÈë²ÎÊýºÍ2¸öÊä³ö²ÎÊýµÄ´æ´¢¹ý³Ì£¬¸÷²ÎÊý¾ùΪÕûÐÍ¡£ÏÂÁж¨Òå¸Ã´æ´¢¹ý³ÌµÄÓï¾ä£¬ÕýÈ·µÄÊÇ D

A£®CREATE PROC P1 @x1, @x2 int,

@x3 , @x4 int output

B£®CREATE PROC P1 @x1 int, @x2 int,

@x2, @x4 int output

C£®CREATE PROC P1 @x1 int, @x2 int,

@x3 int, @x4 int output

D£®CREATE PROC P1 @x1 int, @x2 int,

@x3 int output, @x4 int output t 4£®ÉèÓд洢¹ý³Ì¶¨ÒåÓï¾ä£ºCREATE PROC P1 @x int, @y int output, @z int output¡£ÏÂÁе÷Óøô洢¹ý³ÌµÄÓï¾äÖУ¬ÕýÈ·µÄÊÇ C

A£®EXEC P1 10, @a int output, @b int output B£®EXEC P1 10, @a int, @b int output C£®EXEC P1 10, @a output, @b output D£®EXEC P1 10, @a, @b output 5£®ÏÂÁÐÐ޸Ĵ洢¹ý³ÌP1µÄÓï¾ä£¬ÕýÈ·µÄÓï¾äÊÇ B

A£®ALTER P1 B£®ALTER PROC P1 C£®MODIFY P1 D£®MODIFY PROC P1 6£® ÏÂÁÐɾ³ý´æ´¢¹ý³ÌP1µÄÓï¾ä£¬ÕýÈ·µÄÓï¾äÊÇ D A£®DELETE P1 B£®DELETE PROC P1 C£®DROP P1 D£®DROP PROC P1 7£®¶¨Òå´¥·¢Æ÷µÄÖ÷Òª×÷ÓÃÊÇ D A£®Ìá¸ßÊý¾ÝµÄ²éѯЧÂÊ C£®¼ÓÇ¿Êý¾ÝµÄ±£ÃÜÐÔ

B£®ÔöÇ¿Êý¾ÝµÄ°²È«ÐÔ D£®ÊµÏÖ¸´ÔÓµÄÔ¼Êø

8£®ÏÖÓÐѧÉú±íºÍÐÞ¿Î±í£¬Æä½á¹¹Îª£º

ѧÉú±í£¨Ñ§ºÅ£¬ÐÕÃû£¬ÈëѧÈÕÆÚ£¬±ÏÒµÈÕÆÚ£© ÐÞ¿Î±í£¨Ñ§ºÅ£¬¿Î³ÌºÅ£¬¿¼ÊÔÈÕÆÚ£¬³É¼¨£©

ÏÖÒªÇóÐ޿αíÖеĿ¼ÊÔÈÕÆÚ±ØÐëÔÚѧÉú±íÖÐÏàӦѧÉúµÄÈëѧÈÕÆںͱÏÒµÈÕÆÚÖ®¼ä¡£ÏÂÁÐʵÏÖ·½·¨

37

¡¤38¡¤ ÖУ¬ÕýÈ·µÄÊÇ B

A£®ÔÚÐ޿αíµÄ¿¼ÊÔÈÕÆÚÁÐÉ϶¨ÒåÒ»¸öCHECKÔ¼Êø B£®ÔÚÐ޿αíÉϽ¨Á¢Ò»¸ö²åÈëºÍ¸üвÙ×÷µÄ´¥·¢Æ÷ C£®ÔÚѧÉú±íÉϽ¨Á¢Ò»¸ö²åÈëºÍ¸üвÙ×÷µÄ´¥·¢Æ÷ D£®ÔÚÐ޿αíµÄ¿¼ÊÔÈÕÆÚÁÐÉ϶¨ÒåÒ»¸öÍâÂëÒýÓÃÔ¼Êø

9£®ÉèÓнÌʦ±í£¨½ÌʦºÅ£¬½ÌʦÃû£¬Ö°³Æ£¬»ù±¾¹¤×Ê£©£¬ÆäÖлù±¾¹¤×ʵÄÈ¡Öµ·¶Î§Óë½Ìʦְ³ÆÓйأ¬±ÈÈ磬½ÌÊڵĻù±¾¹¤×ÊÊÇ6000~10000£¬¸±½ÌÊڵĻù±¾¹¤×ÊÊÇ4000~8000¡£ÏÂÁÐʵÏÖ¸ÃÔ¼ÊøµÄ·½·¨ÖУ¬¿ÉÐеÄÊÇ C

A£® ¿Éͨ¹ýÔÚ½Ìʦ±íÉ϶¨Òå²åÈëºÍÐ޸IJÙ×÷µÄ´¥·¢Æ÷ʵÏÖ B£® ¿Éͨ¹ýÔÚ»ù±¾¹¤×ÊÁÐÉ϶¨ÒåÒ»¸öCHECKÔ¼ÊøʵÏÖ C£® AºÍB¶¼¿ÉÒÔ D£® AºÍB¶¼²»¿ÉÒÔ 10£®ÉèÔÚSC(Sno,Cno,Grade)±íÉ϶¨ÒåÁË´¥·¢Æ÷£º

CREATE TRIGGER tri1 ON SC INSTEAD OF INSERT ¡­ µ±Ö´ÐÐÓï¾ä£ºINSERT INTO SC VALUES('s001', 'c01',90)

»áÒý·¢¸Ã´¥·¢Æ÷Ö´ÐС£ÏÂÁйØÓÚ´¥·¢Æ÷Ö´ÐÐʱ±íÖÐÊý¾ÝµÄ˵·¨£¬ÕýÈ·µÄÊÇ A£®SC±íºÍINERTED±íÖоù°üº¬Ð²åÈëµÄÊý¾Ý B£®SC±íºÍINERTED±íÖоù²»°üº¬Ð²åÈëµÄÊý¾Ý

C£®SC±íÖаüº¬Ð²åÈëµÄÊý¾Ý£¬INERTED±íÖв»°üº¬Ð²åÈëµÄÊý¾Ý D£®SC±íÖв»°üº¬Ð²åÈëµÄÊý¾Ý£¬INERTED±íÖаüº¬Ð²åÈëµÄÊý¾Ý 11£®ÉèÔÚSC(Sno,Cno,Grade)±íÉ϶¨ÒåÁË´¥·¢Æ÷£º

CREATE TRIGGER tri1 ON SC AFTER INSERT ¡­

µ±Ö´ÐÐÓï¾ä£ºINSERT INTO SC VALUES('s001', 'c01',90)

»áÒý·¢¸Ã´¥·¢Æ÷Ö´ÐС£ÏÂÁйØÓÚ´¥·¢Æ÷Ö´ÐÐʱ±íÖÐÊý¾ÝµÄ˵·¨£¬ÕýÈ·µÄÊÇ A£®SC±íºÍINERTED±íÖоù°üº¬Ð²åÈëµÄÊý¾Ý B£®SC±íºÍINERTED±íÖоù²»°üº¬Ð²åÈëµÄÊý¾Ý

C£®SC±íÖаüº¬Ð²åÈëµÄÊý¾Ý£¬INERTED±íÖв»°üº¬Ð²åÈëµÄÊý¾Ý D£®SC±íÖв»°üº¬Ð²åÈëµÄÊý¾Ý£¬INERTED±íÖаüº¬Ð²åÈëµÄÊý¾Ý

D

A

12£®µ±Ö´ÐÐÓÉUPDATEÓï¾äÒý·¢µÄ´¥·¢Æ÷ʱ£¬ÏÂÁйØÓڸô¥·¢Æ÷ÁÙʱ¹¤×÷±íµÄ˵·¨£¬ÕýÈ·µÄÊÇ C

A£®ÏµÍ³»á×Ô¶¯²úÉúUPDATED±íÀ´´æ·Å¸ü¸ÄÇ°µÄÊý¾Ý B£®ÏµÍ³»á×Ô¶¯²úÉúUPDATED±íÀ´´æ·Å¸ü¸ÄºóµÄÊý¾Ý

C£®ÏµÍ³»á×Ô¶¯²úÉúINSERTED±íºÍDELETED±í£¬ÓÃINSERTED±í´æ·Å¸ü¸ÄºóµÄÊý¾Ý£¬ÓÃDELETED±í´æ·Å¸ü¸ÄÇ°µÄÊý¾Ý

D£®ÏµÍ³»á×Ô¶¯²úÉúINSERTED±íºÍDELETED±í£¬ÓÃINSERTED±í´æ·Å¸ü¸ÄÇ°µÄÊý¾Ý£¬ÓÃDELETED±í´æ·Å¸ü¸ÄºóµÄÊý¾Ý 13£®ÏÂÁйØÓÚÓαêµÄ˵·¨£¬´íÎóµÄÊÇ D

A£®ÓαêÔÊÐíÓû§¶¨Î»µ½½á¹û¼¯ÖеÄijÐÐ

B£®ÓαêÔÊÐíÓû§¶ÁÈ¡½á¹û¼¯Öе±Ç°ÐÐλÖõÄÊý¾Ý C£®ÓαêÔÊÐíÓû§Ð޸Ľá¹û¼¯Öе±Ç°ÐÐλÖõÄÊý¾Ý

D£®ÓαêÖÐÓиöµ±Ç°ÐÐÖ¸Õ룬¸ÃÖ¸ÕëÖ»ÄÜÔÚ½á¹û¼¯Öе¥ÏòÒƶ¯

14£®¶ÔÓαêµÄ²Ù×÷Ò»°ã°üÀ¨ÉùÃ÷¡¢´ò¿ª¡¢´¦Àí¡¢¹Ø±Õ¡¢Êͷż¸¸ö²½Ö裬ÏÂÁйØÓڹرÕÓαêµÄ˵·¨£¬

38

¡¤39¡¤ ´íÎóµÄÊÇ B

A£®Óα걻¹Ø±ÕÖ®ºó£¬»¹¿ÉÒÔͨ¹ýOPENÓï¾äÔٴδò¿ª B£®ÓαêÒ»µ©±»¹Ø±Õ£¬ÆäËùÕ¼ÓõÄ×ÊÔ´¼´±»ÊÍ·Å C£®Óα걻¹Ø±ÕÖ®ºó£¬ÆäËùÕ¼ÓõÄ×ÊԴûÓб»ÊÍ·Å

D£®¹Ø±ÕÓαêÖ®ºóµÄÏÂÒ»¸ö²Ù×÷¿ÉÒÔÊÇÊÍ·ÅÓα꣬Ҳ¿ÉÒÔÊÇÔٴδò¿ª¸ÃÓαê

¶þ£® Ìî¿ÕÌâ

1£®ÀûÓô洢¹ý³Ì»úÖÆ£¬¿ÉÒÔ_____Êý¾Ý²Ù×÷ЧÂÊ¡£ Ìá¸ß

2£®´æ´¢¹ý³Ì¿ÉÒÔ½ÓÊÜÊäÈë²ÎÊýºÍÊä³ö²ÎÊý£¬¶ÔÓÚÊä³ö²ÎÊý£¬±ØÐëÓÃ_____´ÊÀ´±êÃ÷¡£ OUTPUT 3£®Ö´Ðд洢¹ý³ÌµÄSQLÓï¾äÊÇ_____¡£ EXEC (EXECUTE)

4£®µ÷Óô洢¹ý³Ìʱ£¬Æä²ÎÊý´«µÝ·½Ê½ÓÐ_____ºÍ_____Á½ÖÖ¡£°´²ÎÊýλÖà °´²ÎÊýÃû 5£®Ð޸Ĵ洢¹ý³ÌµÄSQLÓï¾äÊÇ_____¡£ALTER PROC

6£®SQL ServerÖ§³ÖÁ½ÖÖÀàÐ͵Ĵ¥·¢Æ÷£¬ËüÃÇÊÇ_____´¥·¢ÐÍ´¥·¢Æ÷ºÍ_____´¥·¢ÐÍ´¥·¢Æ÷¡£ Ç° ºó

7£®ÔÚÒ»¸ö±íÉÏÕë¶Ôÿ¸ö²Ù×÷£¬¿ÉÒÔ¶¨Òå_____¸öÇ°´¥·¢ÐÍ´¥·¢Æ÷¡£ Ò»

8£®Èç¹ûÔÚij¸ö±íµÄINSERT²Ù×÷É϶¨ÒåÁË´¥·¢Æ÷£¬Ôòµ±Ö´ÐÐINSERTÓï¾äʱ£¬ÏµÍ³²úÉúµÄÁÙʱ¹¤×÷±íÊÇ_____¡£ INSERTED

9£®¶ÔÓÚºó´¥·¢ÐÍ´¥·¢Æ÷£¬µ±´¥·¢Æ÷Ö´ÐÐʱ£¬Òý·¢´¥·¢Æ÷µÄ²Ù×÷Óï¾ä£¨ÒÑÖ´ÐÐÍê/δִÐУ©_____¡£ ÒÑÖ´ÐÐÍê

10£®¶ÔÓÚºó´¥·¢ÐÍ´¥·¢Æ÷£¬µ±ÔÚ´¥·¢Æ÷Öз¢ÏÖÒý·¢´¥·¢Æ÷Ö´ÐеIJÙ×÷Î¥·´ÁËÔ¼Êøʱ£¬ÐèҪͨ¹ý_____Óï¾ä³·ÏúÒÑÖ´ÐеIJÙ×÷¡£ ROLLBACK

11£®´ò¿ªÓαêµÄÓï¾äÊÇ_____¡£ OPEN cursor_name

12£®ÔÚ²Ù×÷Óαêʱ£¬ÅжÏÊý¾ÝÌáȡ״̬µÄÈ«¾Ö±äÁ¿_____¡£ @@fetch_status

ËÄ£®ÉÏ»úÁ·Ï°

ÒÔϸ÷Ìâ¾ùÀûÓõÚ3¡¢4Õ½¨Á¢µÄStudentsÊý¾Ý¿âÒÔ¼°Student¡¢CourseºÍSC±íʵÏÖ¡£ 1£® ´´½¨Âú×ãÏÂÊöÒªÇóµÄ´æ´¢¹ý³Ì£¬²¢²é¿´´æ´¢¹ý³ÌµÄÖ´Ðнá¹û¡£ £¨1£© ²éѯÿ¸öѧÉúµÄÐÞ¿Î×Üѧ·Ö£¬ÒªÇóÁгöѧÉúѧºÅ¼°×Üѧ·Ö¡£

create proc p1 as

select sno,SUM(credit) as ×Üѧ·Ö

from SC join Course c on c.Cno=SC.Cno group by sno

£¨2£© ²éѯѧÉúµÄѧºÅ¡¢ÐÕÃû¡¢Ð޵Ŀγ̺š¢¿Î³ÌÃû¡¢¿Î³Ìѧ·Ö£¬½«Ñ§ÉúËùÔÚϵ×÷ΪÊäÈë²ÎÊý£¬Ä¬

ÈÏֵΪ¡°¼ÆËã»úϵ¡±¡£Ö´Ðд˴洢¹ý³Ì£¬²¢·Ö±ðÖ¸¶¨Ò»Ð©²»Í¬µÄÊäÈë²ÎÊýÖµ£¬²é¿´Ö´Ðнá¹û¡£ create proc p2

@dept varchar(20) = '¼ÆËã»úϵ' as

select s.sno,sname,c.cno,cname,credit from Student s join SC on s.Sno=SC.Sno join Course c on c.Cno=SC.Cno

where Sdept = @dept Ö´ÐÐʾÀý1£ºEXEC P2

Ö´ÐÐʾÀý2£ºEXEC P2 'ͨÐŹ¤³Ìϵ'

39

¡¤40¡¤ £¨3£© ²éѯָ¶¨ÏµµÄÄÐÉúÈËÊý£¬ÆäÖÐϵΪÊäÈë²ÎÊý£¬ÈËÊýΪÊä³ö²ÎÊý¡£

create proc p3

@dept varchar(20),@rs int output as

select @rs = COUNT(*) from Student

where Sdept = @dept and Ssex = 'ÄÐ'

£¨4£© ɾ³ýÖ¸¶¨Ñ§ÉúµÄÐ޿μǼ£¬ÆäÖÐѧºÅΪÊäÈë²ÎÊý¡£

create proc p4 @sno char(7) as

delete from SC where Sno = @sno

£¨5£© ÐÞ¸ÄÖ¸¶¨¿Î³ÌµÄ¿ª¿ÎѧÆÚ¡£ÊäÈë²ÎÊýΪ£º¿Î³ÌºÅºÍÐ޸ĺóµÄ¿ª¿ÎѧÆÚ¡£

create proc p5

@cno char(6),@x tinyint as

update Course set Semester = @x where Cno = @cno

2£® ´´½¨Âú×ãÏÂÊöÒªÇóµÄ´¥·¢Æ÷£¨Ç°´¥·¢Æ÷¡¢ºó´¥·¢Æ÷¾ù¿É£©£¬²¢ÑéÖ¤´¥·¢Æ÷Ö´ÐÐÇé¿ö¡£ £¨1£© ÏÞÖÆѧÉúµÄÄêÁäÔÚ15~45Ö®¼ä¡£

create trigger tri1

on student after insert,update as

if exists(select * from inserted where sage not between 15 and 45) rollback £¨2£© ÏÞÖÆѧÉúËùÔÚϵµÄÈ¡Öµ·¶Î§Îª{¼ÆËã»úϵ£¬ÐÅÏ¢¹ÜÀíϵ£¬Êýѧϵ£¬Í¨ÐŹ¤³Ìϵ}

create trigger tri2

on student after insert,update as

if exists(select * from student where sdept not in

('¼ÆËã»úϵ','ÐÅÏ¢¹ÜÀíϵ','Êýѧϵ','ͨÐŹ¤³Ìϵ'))

Rollback

£¨3£© ÏÞÖÆÿ¸öѧÆÚ¿ªÉèµÄ¿Î³Ì×Üѧ·ÖÔÚ20~30·¶Î§ÄÚ¡£

create trigger tri3

on course after insert,update as

if exists(select sum(credit) from course

where semester in (select semester from inserted ) having sum(credit) not between 20 and 30 ) Rollback

40