Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

oracleѧϰ£¨´´½¨±í£©

ÎÒÏë×î³õѧϰÊý¾Ý¿âʱ¶¼ÊÇÒÔ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','


Ïà¹ØÎĵµ£º

OracleÖжà±í²éѯÔÙ°´Ê±¼äµ¹Ðò

ÎÒÔÚ¹¤×÷ÖÐÔÚOracleÖжà±í²éѯÔÙ°´Ê±¼äµ¹Ðòʱ£¬ÓÃorder by ±íÃû.datatime desc ×ÜÊÇʵÏÖ²»ÁË¡£
²»¹ý×îºóÎÊÑî¾é×îºóºÍÎÒ˵¿ÉÒÔ°ÑÎÒÃDzéѯµÄ×ܸösqlÓï¾ä×öΪһ¸ö±íÀ´ÅÅÐò£º
select rownum,aa.* from (....  order by ±íÃû.datatime desc ) aa ......

¡¾×ª¡¿ Oracle group by¼°ÆäÈô¸ÉÏà¹Øº¯ÊýµÄһЩ˵Ã÷

Oracle group by¼°ÆäÈô¸ÉÏà¹Øº¯ÊýµÄһЩ˵Ã÷
http://blog.csdn.net/roland_wg/archive/2009/07/03/4319323.aspx
OracleµÄgroup by³ýÁË»ù±¾Ó÷¨ÒÔÍ⣬»¹ÓÐ3ÖÖÀ©Õ¹Ó÷¨£¬·Ö±ðÊÇrollup¡¢cube¡¢grouping sets¡£
¼ÙÉèÓÐÒ»¸ö±ítest£¬ÓÐA¡¢B¡¢C¡¢D¡¢E5ÁС£
1£© Èç¹ûʹÓÃgroup by rollup(A,B,C)£¬Ê×ÏÈ»á¶Ô(A¡¢B¡¢C)½øÐÐGROUP BY ......

oracleÖеÄÊÓͼ


create table a(
id number primary key,
name varchar2(20)
);
create table b(
id number,
name varchar2(20),
aid number references a(id)
);
insert into a values(1,'1');
insert into b values(1,'aaa',1);
Èç¹û create view vi_new as select * from a
ÔÚÊÓͼvi_new ÉÏ×öÈκΠdml²Ù×÷¶¼»áÐÞ¸Ä ¶ÔÓ¦µÄ ......

Oracle Group By Ó÷¨Ö® —— Having

¿Í»§ÐèÇó·ÖÎö£º
¡¡¡¡±ÊÕß×î½ü½Óµ½Ò»¼Ò¿Í»§µÄÒ»¸öÐèÇó¡£ËûÃDz¿ÊðÁËÒ»¸öERPϵͳ£¬ÏÖÔÚ²ÉÓõľÍÊÇOracleÊý¾Ý¿â¡£ÏÖÔÚÓÉÓÚÆóҵͳ¼Æ·ÖÎöµÄÐèÒª£¬ÒªÊµÏÖÈçϵÄÐèÇó¡£
¡¡¡¡1¡¢°´Ô·ÝÀ´Í³¼Æ2009ÄêµÚÒ»¼¾¶Èÿ¸ö¹©Ó¦É̵IJɹº½ð¶î¡£Ò²¾ÍÊÇ˵£¬ÔÚ±¨±íÖÐÒªÄܹ»ÏÔʾ³ö2009Äê1Ô·ݡ¢2Ô·ݡ¢3Ô·ݹ©Ó¦É̵IJɹº½ð¶îºÏ¼Æ£¬²»ÐèÒªÃ÷ϸ¡£
¡¡¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ