OracleÖеÄÊý×é
2010-04-21 14:04
oracleÖй¹ÔìÊý×éµÄÀý×Ó£º
declare
type t_varray is varray(4) of number;
arr t_varray;
begin
arr := t_varray(1,2,3,4);
for i in 1..arr.count loop
dbms_output.put_line(arr(i));
end loop;
end;
¹¹Ôì¶þάÊý×éµÄÀý×Ó£º
declare
type t_varray is varray(4) of number;
type t_varray_varray is varray(3) of t_varray;
arr t_varray;
v_arr t_varray_varray;
begin
arr := t_varray(1,2,3,4);
v_arr := t_varray_varray(arr,arr,arr);
for i in 1..v_arr.count loop
for j in 1..v_arr(i).count loop
dbms_output.put(v_arr(i)(j));
if (j = v_arr(i).count) then
dbms_output.put_line('');
end if;
end loop;
end loop;
end;
³ýÁËʹÓÃvarray£¬»¹¿ÉÒÔʹÓÃË÷Òý±í¹¹ÔìÊý×顣ʹÓÃË÷Òý±í¶¨ÒåÊý×飬²»ÐèÒªÖ¸¶¨Êý×éµÄÉÏÏÞ£¬Êý×éµÄ´óСֻÓëÄÚ´æÏÞÖÆÓйء£¶øÇÒË÷Òý×éÖ¯±í¶¨ÒåÊÇÖ¸¶¨µÄË÷ÒýÏî²¢²»Ò»¶¨ÒªÊÇÊýÖµ¡£(ÏÂÒ»¸öÀý×ÓÊÇsysÓû§ÖеÄÀý×Ó)
DECLARE
TYPE T_TAB IS TABLE OF NUMBER INDEX BY VARCHAR2(30);
V_VAR T_TAB;
V_STR VARCHAR2(30);
BEGIN
FOR I IN (SELECT OWNER, COUNT(*) CN from DBA_TABLES GROUP BY OWNER) LOOP
V_VAR(I.OWNER) := I.CN;
END LOOP;
V_STR := V_VAR.FIRST;
WHILE (V_VAR.EXISTS(V_STR)) LOOP
DBMS_OUTPUT.PUT_LINE(RPAD(V_STR, 20, ' ') || ':' || V_VAR(V_STR));
V_STR := V_VAR.NEXT(V_STR);
END LOOP;
END;
Èç¹û¹¹Ôì¶þάÒÔÉϵÄÊý×飬ÇÒά¶È²»È«ÊÇÊýÖµ£¬ÄÇô¾ÍÐèҪעÒâÁË£º
DECLARE
TYPE T_NUM_TAB IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
TYPE T_VAR_TAB IS TABLE OF NUMBER INDEX BY VARCHAR2(10);
TYPE T_NUM_VAR IS TABLE OF T_NUM_TAB INDEX BY VARCHAR2(10);
TYPE T_VAR_NUM IS TABLE OF T_VAR_TAB INDEX BY BINARY_INTEGER;
V_NUM_VAR T_NUM_VAR;
V_VAR_NUM T_VAR_NUM;
BEGIN
V_NUM_VAR(5)('A') := 1;
V_VAR_NUM('A')(5) := 1;
END;
&nbs
Ïà¹ØÎĵµ£º
oracleÓû§¹ÜÀí
  ......
ÔÚ¹úÄÚÍâÐí¶àOracle DBAÕ¾µãÉÏ£¬Óкܶà²éÕÒ±íÖеÚn¸ö×î´óÖµµÄС¼¼ÇÉ£¬ÕâЩÓï¾äȷʵÏ൱ÇÉÃËüÃǶ¼¶À±Ùõ辶µØÓõ½ÁËOracle±íÖеÄÒ»¸öα×ֶΓlevel”¡£µ«ÊÇÔںܶàÇé¿öÏ£¬Õâ¸öÓï¾ä±ä³ÉÁË ÃÀÀöµÄÏÝÚå¡£Èç¹ûÄãÏëÖªµÀΪʲô£¬²¢ÔõÑùÈƹýËü£¬ÇëÌýÎÒµÀÀ´£¡
Ñо¿Á˼¸Ì죬ÎÒ·¢ÏÖÒ»ÖÖÑÜÉúËã·¨£¬¼´ÕÒ³öµÚn¸öºÍµÚm¸ö×î´óÖ ......
oracleÆô¶¯ÎÊÌâ
Ò»£ºÊý¾Ý¿âûÓÐÆô¶¯
#sqlplus /nolog
sql>connect /as sysdba
sql>startup
¶þ£º¼àÌý³öÎÊÌâ
µÇ¼DB·þÎñÆ÷
ʹÓÃlsnrctl start/stop¿ªÆô/¹Ø±Õ¼àÌý
ʹÓÃlsnrctl status²é¿´×´Ì¬
ÀíӦΪ£º
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ERPAP)(PORT=1521)))
STATUS of the ......
ÎÒÃÇ¿ÉÒÔͨ¹ýSTART WITH . . . CONNECT BY . . .×Ó¾äÀ´ÊµÏÖSQLµÄ ²ã´Î²éѯ£¬¶øOracle 10g ΪÆäÌí¼ÓÐí¶àÁËеÄαÁС£Ê®¶àÄêÒÔÀ´£¬Oracle SQL ¾ßÓÐÒÀÕÕ²ã´Î¹Øϵ½øÐвéѯµÄ¹¦ÄÜ¡£ÀýÈ磬Äã¿ÉÒÔÖ¸¶¨Ò»¸öÆðʼÌõ¼þ£¬È»ºó¸ù¾ÝÒ»¸ö»ò¶à¸öÁ¬½ÓÌõ¼þÀ´È·¶¨º¢×ÓÐеÄÄÚÈÝ¡£¾ÙÀýÀ´Ëµ£¬ÏÖÔÚ¼ÙÉèÎÒÓÐÒ»¸ö±í£¬ÀïÃæ¼Ç ......
CREATE OR REPLACE PROCEDURE kevin_proc(x varchar) IS
a VARCHAR(20);
b VARCHAR(20);
CURSOR mycur(rn NUMBER) IS SELECT * from t_kevin_test WHERE ROWNUM<rn;
BEGIN
OPEN mycur(10);
LOOP FETCH mycur INTO a,b;
EXIT WHEN mycur%NOTFOUND;
Dbms_Output.put_line('a: '||a);
Dbms_Output.put_line('b: '| ......