Oracle¸ß¼¶²éѯ
ʹÓÃOracleÌØÓеIJéѯÓï·¨, ¿ÉÒԴﵽʰ빦±¶µÄЧ¹û
1. Ê÷²éѯ
create table tree (
id number(10) not null primary key,
name varchar2(100) not null,
super number(10) not null // 0 is root
);
-- ´Ó×Óµ½¸¸
select * from tree start with id = ? connect by id = prior super
-- ´Ó¸¸µ½×Ó
select * from tree start with id = ? connect by prior id = super
-- Õû¿ÃÊ÷
select * from tree start with super = 0 connect by prior id = super
2. ·ÖÒ³²éѯ
select * from (
select my_table.*, rownum my_rownum from (
select name, birthday from employee order by birthday
) my_table where rownum < 120
) where my_rownum >= 100;
3. ÀÛ¼Ó²éѯ, ÒÔscott.empΪÀý
select empno, ename, sal, sum(sal) over(order by empno) result from emp;
EMPNO ENAME SAL RESULT
---------- ---------- ---------- ----------
7369 SMITH 800 800
7499 ALLEN &
Ïà¹ØÎĵµ£º
ѧϰOracle DBAÒ²°ë¸ö¶àѧÆÚÁË£¬½ñÌìÃÍÈ»²Å·¢ÏÖ£¬ÔÀ´ÎÒµÄÊ黹ÊǺÜеģ¬ÉϿβÙ×÷ʱºòÒ²Ö»ÊÇÖªµÀ´ó¸ÅÔõô×ö£¬µ«ÊÇÒªÕæµÄÈ«²¿×Ô¼º×ö£¬¶ø²»È¥·Ê黹ÊÇÓÐÒ»¶¨µÄÄѶȵģ¬ËùÒÔÄØ£¬½ñÌ쿪ʼ½«DBA´ÓÍ·¸´Ï°Ò»±é£¬Í¬Ê±ÔÙ²Ù×÷Ò»±é¡£
µÚÒ»Õ£¬Ñ§µÄÊÇOracleµÄÌåϵ½á¹¹£ ......
²é¿´±íµÄ´óС£»
select a.blocks,a.bytes,a.bytes/1024/1024 from user_segments a
where a.segment_name='B_M_DZYH_CUST_SIGN_FACT';
Ê×ÏÈ
create table TEST_1228 as select * from user_tables;
insert into TEST_1228 select * from TEST_1228 ;
insert into TEST_1228 select * from TEST_1228 ;
i ......
extent--×îС¿Õ¼ä·ÖÅ䵥λ --tablespace management
block --×îСi/oµ¥Î» --segment management
create tablespace james
datafile '/export/home/oracle/oradata/james.dbf'
size 100M ¡¡¡¡¡¡¡¡¡¡¡¡--³õʼµÄÎļþ´óС¡¡
autoextend On¡¡¡¡¡¡¡¡ --×Ô¶¯Ôö³¤
next 10M¡ ......
1¡¢Ê¹ÓÃ%TYPE
ÔÚÐí¶àÇé¿öÏ£¬PL/SQL±äÁ¿¿ÉÒÔÓÃÀ´´æ´¢ÔÚÊý¾Ý¿â±íÖеÄÊý¾Ý¡£ÔÚÕâÖÖÇé¿öÏ£¬±äÁ¿Ó¦¸ÃÓµÓÐÓë±íÁÐÏàͬµÄÀàÐÍ¡£ÀýÈ磬students±íµÄfirst_nameÁеÄÀàÐÍΪVARCHAR2(20),ÎÒÃÇ¿ÉÒÔ°´ÕÕÏÂÊö·½Ê½ÉùÃ÷Ò»¸ö±äÁ¿
DECLARE
v_FirstName VARCHAR2(20);
µ«ÊÇÈç¹ûfirst_nameÁеĶ¨Òå¸Ä±äÁ˻ᷢÉúʲô£¨±ÈÈç˵±í¸Ä±äÁË£¬first ......