ÎÒÏë×î³õѧϰÊý¾Ý¿âʱ¶¼ÊÇÒÔstudent±í¡¢course±íºÍsc±íΪÀýµÄ°É
Ê×ÏÈ´´½¨ÕâÈýÕÅ±í£º±ØÒªÊ±¿ÉÖØÐ´´½¨Óû§¼°ÃÜÂë²¢µÇ½
»·¾³£ºoracle 10g
declare
vcnt number;
begin
select count(*) into vcnt from user_tables where table_name='SC';
If vcnt = 1 Then
Execute immediate 'drop table sc';
end if;
select count(*) into vcnt from user_tables where table_name='STUDENT';
If vcnt = 1 Then
Execute immediate 'drop table student';
end if;
select count(*) into vcnt from user_tables where table_name='COURSE';
If vcnt = 1 Then
Execute immediate 'drop table course';
end if;
end;
/
--´´½¨±í
Create table student
(sno char(10) primary key,
sname varchar(20) not null,
sage smallint,
ssex char(2),
sdept varchar(20));
Create table course
(cno char(10) primary key,
cname varchar(20) not null,
credit smallint);
Create table sc
(sno char(10),
cno char(10),
grade smallint,
primary key(sno,cno));
--Ïò±íÖвåÈëÊý¾Ý
insert into student values('001','¸ðÁé','19','f','MA');
insert into student values('002','ÔÀÁÖÔÂ','25','f','MA');
insert into student values('003','¼§Ê¤¿¡','16','f','CS');
insert into student values('004','ÂíÔ´','20','f','MA');
insert into student values('005','ÎÌÓ¡','23','m','C');
insert into course values('C01','CÓïÑÔ','4');
insert into course values('C02','Êýѧ','4');
insert into course values('C03','Ó¢Óï','2');
insert into course values('C04','¼ÆËã»ú','5');
insert into course values('C05','Êý×Öµç·','3');
insert into course values('C06','Êý¾Ý¿â','2');
--001ºÅѧÉúÑ¡Ð޿γÌ
insert into sc values('001','C05','75');
insert into sc values('001','C01','68');
insert into sc values('001','C03','86');
insert into sc values('001','C02','40');
insert into sc values('001','C04','97');
--002ºÅѧÉúÑ¡Ð޿γÌ
insert into sc values('002','C01','60');
insert into sc values('002','
ÔÚplsqlÖУ¬ÃæÏò¶ÔÏóµÄ³ÌÐòÉè¼ÆÊÇ»ùÓÚ¶ÔÏóÀàÐÍÀ´Íê³ÉµÄ¡£¶ÔÏóÀàÐÍÊÇÓû§×Ô¶¨ÒåµÄÒ»ÖÖ¸´ºÏÊý¾ÝÀàÐÍ£¬Ëü·â×°ÁËÊý¾Ý½á¹¹ºÍÓÃÓÚ²Ù×ÝÕâЩÊý¾Ý½á¹¹µÄ¹ý³ÌºÍº¯Êý£¬ÔÚ½¨Á¢¸´ÔÓÓ¦ÓóÌÐòʱ£¬Í¨¹ýʹÓöÔÏóÀàÐÍ¿ÉÒÔ½µµÍÓ¦Óÿª·¢ÄѶȣ¬½ø¶øÌá¸ßÓ¦Óÿª·¢µÄЧÂʺÍËÙ¶È¡£
¶ÔÏóÀàÐͰüÀ¨¶ÔÏóÀàÐ͹淶£¨object type specification£©ºÍ¶ÔÏóÀàÐÍ ......
˵Ã÷:ÏÂÎÄÖеÄһЩ˵Ã÷ºÍʾÀý´úÂëÕª×ÔCSDN,Ë¡²»Ò»Ò»Ö¸Ã÷³ö´¦,ÔÚ´ËÒ»²¢¶ÔÏà¹Ø×÷Õß±íʾ¸Ðл!
¡¡¡¡1 Óï·¨
¡¡¡¡ÔÚOracleÖУ¬¿ÉÒÔ´´½¨ÒÔÏÂÁ½ÖÖÁÙʱ±í£º
¡¡¡¡1) »á»°ÌØÓеÄÁÙʱ±í
¡¡¡¡CREATE GLOBAL TEMPORARY ( )
¡¡¡¡ON COMMIT PRESERVE ROWS£»
¡¡¡¡2) ÊÂÎñÌØÓеÄÁÙʱ±í
¡¡¡¡CREATE GLOBAL TEMPORARY ( )
¡¡¡¡O ......