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 &
Ïà¹ØÎĵµ£º
Èç¹ûÔÚÊÂÎñÖÐÖ´ÐÐÁËÒ»Ìõ²»Âú×ãÌõ¼þµÄupdateÓï¾ä£¬ÔòÖ´ÐÐÈ«±íɨÃ裬°ÑÐм¶ËøÉÏÉýΪ±í¼¶Ëø£¬¶à¸öÕâÑùµÄÊÂÎñÖ´Ðк󣬾ͺÜÈÝÒײúÉúËÀËø¡£
ËÀËøÒ»°ãÊÇÒò×¾ÁÓµÄÊÂÎñÉè¼Æ¶ø²úÉú insert, update, delete
1.°´Óû§Óëϵͳ»®·Ö£¬¿ÉÒÔ·ÖΪ×Ô¶¯ËøÓëÏÔÊ¾Ëø
×Ô¶¯Ëø£ºµ±½øÐÐÒ»ÏîÊý¾Ý¿â²Ù×÷ʱ£¬È±Ê¡Çé¿öÏ£¬ÏµÍ³×Ô¶¯Îª´ËÊý¾Ý¿â²Ù×÷»ñµÃËùÓ ......
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£©¡¢¹¹ÔìʵÀý£º
ÎÒÃÇÒѾ´´½¨ºÃÊý¾Ý¿âÓû§test_user£¬Ï±ߴæÔÚtest_table±íºÍtest_procedure´æ´¢¹ý³Ì¡£ÎÒÃÇÒѾ´´½¨ºÃÒ»¸ö¿ÕµÄ´úÀíÊý¾Ý¿âÓû§agent_user¡£
2£©¡¢µÇ¼test_userÓû§£¬½«test_userϱíµÄselectȨÏ޺ʹ洢¹ý³ÌµÄexcuteȨÏÞ¸³¸ø´úÀíÓû§agent_user¡£
SQL>GRANT select ON test_table TO agent_user;
SQL ......
1¡¢Ê¹ÓÃ%TYPE
ÔÚÐí¶àÇé¿öÏ£¬PL/SQL±äÁ¿¿ÉÒÔÓÃÀ´´æ´¢ÔÚÊý¾Ý¿â±íÖеÄÊý¾Ý¡£ÔÚÕâÖÖÇé¿öÏ£¬±äÁ¿Ó¦¸ÃÓµÓÐÓë±íÁÐÏàͬµÄÀàÐÍ¡£ÀýÈ磬students±íµÄfirst_nameÁеÄÀàÐÍΪVARCHAR2(20),ÎÒÃÇ¿ÉÒÔ°´ÕÕÏÂÊö·½Ê½ÉùÃ÷Ò»¸ö±äÁ¿
DECLARE
v_FirstName VARCHAR2(20);
µ«ÊÇÈç¹ûfirst_nameÁе͍Òå¸Ä±äÁ˻ᷢÉúʲô£¨±ÈÈç˵±í¸Ä±äÁË£¬first ......
ÔÚ´¦ÀíÊý¾Ýʱ·¢ÏÖÒ»¸öÎÊÌ⣬Oracle¶ÔÓÚСÓÚ1µÄСÊý£¬Ð¡ÊýµãÇ°ÃæµÄ0ÊDz»ÏÔʾµÄ¡£
SQL> create table t1_number (num number);
Table created
SQL> insert into t1_number values(0.3268);
1 row inserted
SQL> insert into t1_number values(0.57965686);
1 row inserted
&nb ......