Oracle ¶¯Ì¬SQL·µ»Øµ¥Ìõ½á¹ûºÍ½á¹û¼¯
Oracle ¶¯Ì¬SQL·µ»Øµ¥Ìõ½á¹ûºÍ½á¹û¼¯
1. DDL ºÍ DML
/**//*** DDL ***/
begin
EXECUTE IMMEDIATE 'drop table temp_1';
EXECUTE IMMEDIATE 'create table temp_1(name varchar2(8))';
end;
/**//*** DML ***/
declare
v_1 varchar2(8);
v_2 varchar2(10);
str varchar2(50);
begin
v_1:='²âÊÔÈËÔ±';
v_2:='±±¾©';
str := 'INSERT INTO test (name ,address) VALUES (:1, :2)';
EXECUTE IMMEDIATE str USING v_1, v_2;
commit;
end;
2. ·µ»Øµ¥Ìõ½á¹û
declare
str varchar2(500);
c_1 varchar2(10);
r_1 test%rowtype;
begin
c_1:='²âÊÔÈËÔ±';
str:='select * from test where name=:c WHERE ROWNUM=1';
execute immediate str into r_1 using c_1;
DBMS_OUTPUT.PUT_LINE(R_1.NAME||R_1.ADDRESS);
end ;
3. ·µ»Ø½á¹û¼¯
CREATE OR REPLACE package pkg_test as
/**//* ¶¨Òåref cursorÀàÐÍ
²»¼ÓreturnÀàÐÍ£¬ÎªÈõÀàÐÍ£¬ÔÊÐí¶¯Ì¬sql²éѯ£¬
·ñÔòΪǿÀàÐÍ£¬ÎÞ·¨Ê¹Óö¯Ì¬sql²éѯ;
*/
type myrctype is ref cursor;
--º¯ÊýÉêÃ÷
function get(intID number) return myrctype;
end pkg_test;
/
CREATE OR REPLACE package body pkg_test as
--º¯ÊýÌå
function get(intID number) return myrctype is
rc myrctype; --¶¨Òåref cursor±äÁ¿
sqlstr varchar2(500);
begin
if intID=0 then
--¾²Ì¬²âÊÔ£¬Ö±½ÓÓÃselectÓï¾äÖ±½Ó·µ»Ø½á¹û
open rc for select
Ïà¹ØÎĵµ£º
ÔÚOracleÖн¨¿â£¬Í¨³£ÓÐÁ½ÖÖ·½·¨¡£Ò»ÊÇʹÓÃOracleµÄ½¨¿â¹¤
ÇÒDBCA£¬ÕâÊÇÒ»¸öͼÐνçÃ湤ÇÒ£¬Ê¹ÓÃÆðÀ´·½±ãÇÒºÜÈÝÒ×Àí½â£¬ÒòΪËüµÄ½çÃæÓѺá¢ÃÀ¹Û£¬¶øÇÒÌáʾҲ±È½ÏÆëÈ«¡£ÔÚ£×indowsϵͳÖУ¬Õâ¸ö¹¤¾ß¿ÉÒÔÔÚOracle³ÌÐò×éÖдò¿ª£¨”¿ªÊ¼”—“³ÌÐò”—“ Oracle OraDb10g_home1”&mdash ......
ÃüÁîÐÐά»¤Oracle AWR
ÓÐʱºòÓÉÓÚÖÖÖÖÔÒò£¬Ö»ÄÜʹÓÃÃüÁîÐÐÀ´Î¬»¤Oracle10g¡£µ±È»ÎÒÃÇÒÀÈ»¿ÉÒÔʹÓÃstatspack£¬µ«ÓÉÓÚstatspack¹¦Äܲ»ÈçAWR£¬¶ø
ÇÒÈç¹ûʹÓÃÁ½ÖÖÐÔÄÜÕï¶Ï¹¤¾ßÒ²ÊÇÒ»ÖÖÀË·Ñ¡£Òò´ËÊÖ¶¯Î¬»¤AWR»¹ÊÇÓбØÒªµÄ£¬ÏÂÃæÁгöһЩ³£ÓõÄAWRÃüÁÒÔ±¸ºó²é¡£
1¡¢ÐÞ¸ÄAWRµÄ´¥·¢ÆµÂÊ
......
Ò»¡¢ÏµÍ³µÄĬÈÏÓû§
Java´úÂë
sys;//ϵͳ¹ÜÀíÔ±£¬ÓµÓÐ×î¸ßȨÏÞ
system;//±¾µØ¹ÜÀíÔ±£¬´Î¸ßȨÏÞ
scott;//ÆÕͨÓû§£¬ÃÜÂëĬÈÏΪtiger,ĬÈÏδ½âËø
¶þ¡¢µÇ½
Java´úÂë
sqlplus conn / as sysdba;//µÇ½sysÕÊ»§ ......
Ò»¡¢Enterprise Manager 10g
ĬÈÏÇé¿öÏ£¬°²×°Oracleʱ£¬»á°²×°EM¡£ËüÊÇλÓÚÊý¾Ý¿â·þÎñÆ÷ÉϵÄHTTP·þÎñÆ÷¡£
£¨1£©Æô¶¯EM
Ҫȷ±£OracleDBConsole<SID>·þÎñÒѾÆô¶¯¡£
Æô¶¯·þÎñ£ºemctl start dbconsole
¹Ø±Õ·þÎñ£ºemctl stop dbconsole
·ÃÎÊEM£ºhttp://·þÎñÆ÷Ãû³Æ£º¶Ë¿ÚºÅ/em
¶Ë¿ÚºÅ¿ÉÔÚ$ORACLE_HOME/install/pro ......
HWMÊÇoracleÖÐblockÓÐûÓÐʹÓõķֽçÏߣ¬Ëü»áËæ×ÅÊý¾ÝµÄinsert¶øÉÏÉý£¬µ«Ëü²¢²»»áËæÊý¾ÝµÄdelete¶øϽµ£¬Òò´ËÈ«±íɨÃèµÄʱ¼ä²¢²»ÒòÊý¾ÝµÄdelete¶ø¼õÉÙ£¬Ïà·´¿ÉÄÜÓÉÓÚ¿éÇå³ý·´¶øÈ«±íɨÃèʱ¼äÔö¼Ó£¬¿ÉÒÔÓÃÏÂÃæ·½·¨µÄÈÎÒ»Ò»ÖÖÀ´½µµÍHWM£º
µÚÒ»ÖÖ£ºshrink
ÊÊÓÃÓÚ10gÒÔºóµÄ°æ±¾£¬Ç°ÌáÊÇÕâ¸ö±í£¬Ë÷Òý£¬ÎﻯÊÓͼ»òÎﻯÊÓͼlogËùÔ ......