oracle ÐÐתÁеÄͨÓùý³Ì
ÔÎÄ´«ËÍÃÅ£ºhttp://topic.csdn.net/u/20091019/11/67cd55a3-3f42-4db7-a3f8-91dd52a913cd.html?24122
¾³£Óöµ½·¢ÌûÇóÐÐÁÐת»»µÄ´úÂ룬ÓÃmax(decode(..))»Ø¸´ºó£¬Ê®Óа˾ŻáÔÙÎÊÒ»¾ä£ºÈç¹ûÁÐÃû²»¹Ì¶¨£¬»òÕßÁÐÊý²»¹Ì¶¨Ôõô°ì¡£¾ÍÒªÓô洢¹ý³ÌÀ´Ð´£¬ÕâЩ´æ´¢¹ý³ÌµÄ´úÂ붼´óͬСÒ죬ÎÒ¾ÍÏëÄܲ»ÄÜд¸öͨÓõãµÄ¹ý³Ì
ÊÔÁËһϣ¬°Ñ½á¹û·¢³öÀ´
SQL code
create or replace procedure proc(tabname in varchar2,
col1 in varchar2,
col2 in varchar2,
col3 in varchar2,
viewname in varchar2 default 'v_tmp')
as
sqlstr varchar2(2000):='create or replace view '||viewname||' as select '||col1||' ';
c1 sys_refcursor;
v1 varchar2(100);
begin
open c1 for 'select distinct to_char('||col2||') from '||tabname;
loop
fetch c1 into v1;
exit when c1%notfound;
sqlstr:=sqlstr||'
,max(decode('||col2||','''||v1||''','||col3||'))"'||v1||'"';
end loop;
close c1;
sqlstr:=sqlstr||' from '||tabname||' group by '||col1;
execute immediate sqlstr;
end proc;
ÕâÀïµÄ¼¸¸ö²ÎÊý£¬tabnameÖ¸µÄÊÇÐèÒª½øÐÐÐÐÁÐת»»µÄ±íÃû£¬col1ÊÇÕâ¸ö±íÖÐÐÐÁÐת»»ÒÔºóÒª¸ù¾ÝÄÄÒ»ÁнøÐзÖ×飬ÄÇÒ»ÁеÄÁÐÃû¡£col2´«ÈëµÄÊÇÒª½«ÐÐת³ÉÁеÄÄÇÒ»ÁеÄÁÐÃû£¬col3±íʾÐèÒª½øÐÐͳ¼ÆµÄÊý¾ÝÁеÄÁÐÃû
viewname´«ÈëÏ£Íû½¨Á¢µÄÊÓͼµÄÃû³Æ£¬¿ÉÒÔ²»ÌĬÈÏΪv_tmp
Õâô˵ºÜÄÑÈÃÈËÃ÷°×..¾Ù¸öÀý×Ó£¬ÒýÓÃÒ»¸öÌû×ÓµÄÊý¾Ý
create table tab (
counter varchar(20), -- ²Î¼Ó¿¼ÊÔÈËÊý
subject varchar(20), -- ¿ÆÄ¿
class varchar(20) -- °à¼¶
)
±íÊý¾Ý£º
counter subject class
36 Ó¢Óï Ò»°à
44 Ó¢Óï ¶þ°à
44 Êýѧ ¶þ°à
33 ÓïÎÄ Ò»°à
39 ÓïÎÄ Èý°à
ת»»ºó£º
Ïà¹ØÎĵµ£º
¹Ø¼ü×Ö: oracle job ¼ä¸ôʱ¼ä trunc
¼ÙÉèÄãµÄ´æ´¢¹ý³ÌÃûΪPROC_RAIN_JM
ÔÙдһ¸ö´æ´¢¹ý³ÌÃûΪPROC_JOB_RAIN_JM
ÄÚÈÝÊÇ£º
Create Or Replace Procedure PROC_JOB_RAIN_JM Is li_jobno Number; &nb ......
×÷ΪoracleµÄÏúÊÛÕæÐÄÕæÒâµÄÔÒâÓë´ó¼Ò·ÖÏíoracleµÄÒ»ÇУ¬ÎÒÕâ±ß²»ÊÇÇþµÀ£¬ÊÇoracle×ÊÉî×Ü´úÀí£¨ÖйúÈí¼þÓë¼¼Êõ·þÎñ¹É·ÝÓÐÏÞ¹«Ë¾£©£¬Ï£Íû´ó¼ÒÓйºÂòoracleÒâÔ¸µÄʱºò¼ÇµÃÎÒ£¨ÕÔÌìÊæ 15010529916£©£¬ÎһᾡÎÒËùÄܵİïÖú´ó¼Ò¡£
×î½üÓкܶàÈËÎÊÎÒoracleµÄ¹ºÂò·½Ê½£ºÔÚÕâÀïÎÒÏë²ûÊöµÄÊÇÉÌÎñÉϵĹºÂò· ......
ÏÂÎçÈ¥²Î¼ÓÒ»¸öOracleÓйغ£Á¿Êý¾Ý´æ´¢¼¼ÊõµÄÅàѵ½²×ùÁË¡£
µØÖ·ÔÚ¹ãÖÝÊÐÁÖºÍÎ÷·101ºÅÌìºÓÇø¼Æ¾´óÂ¥Î÷²àÈýÂ¥¡£
Åàѵ·¢Æð»ú¹¹Îª£º¹ãÖÝÖÐî£ÐÅÏ¢¼¼ÊõÓÐÏÞ¹«Ë¾¡£
ÏÂÃæ¾Í¼òÒª×ܽáÒ»ÏÂËùÌýµ½µÄһЩ¶«Î÷£¬Ò²ËãÊÇѧµ½µÄÕâЩ¼¼Êõ¡£²»¹ýÓеĶ«Î÷²»ÖªµÀ×ܽáµÄ¶Ô²»¶Ô£¬ÔÝÇÒàñàðÍÌÔæ°É¡£
OracleµÄ´æ´¢¼¼Êõ
´óÌåÉÏ· ......
¡¡¡¡OracleµÄ·ÖÇø¼¼ÊõÔÚijЩÌõ¼þÏ¿ÉÒÔ¼«´óµÄÌá¸ß²éѯµÄÐÔÄÜ£¬ËùÒÔ±»¹ã·º²ÉÓᣴӲúÆ·ÉÏ˵£¬·ÖÇø¼¼ÊõÊÇOracleÆóÒµ°æÖжÀÁ¢ÊշѵÄÒ»¸ö×é¼þ¡£ÒÔÏÂÊǶÔÓÚ·ÖÇø¼°±¾µØË÷ÒýµÄÒ»¸öʾÀý¡£
¡¡¡¡OracleµÄ·ÖÇø¼¼ÊõÔÚijЩÌõ¼þÏ¿ÉÒÔ¼«´óµÄÌá¸ß²éѯµÄÐÔÄÜ£¬ËùÒÔ±»¹ã·º²ÉÓᣴӲúÆ·ÉÏ˵£¬·ÖÇø¼¼ÊõÊÇOracleÆóÒµ°æÖжÀÁ¢ÊշѵÄÒ»¸ö ......
http://www.csip.com.cn/88/n-52488.html
¹ØÓÚ·ÖÇø±íºÍ·ÖÇøË÷Òý(About Partitioned Tables and Indexes)¶ÔÓÚ10gR2¶øÑÔ£¬»ù±¾ÉÏ¿ÉÒԷֳɼ¸Àࣺ
Range(·¶Î§)·ÖÇø
Hash(¹þÏ£)·ÖÇø
List(Áбí)·ÖÇø
ÒÔ¼°×éºÏ·ÖÇø£ºRange-Hash,Range-List¡£
¶ÔÓÚ±í¶øÑÔ(³£¹æÒâÒåÉϵĶÑ×éÖ¯±í)£¬ÉÏÊö·ÖÇøÐÎʽ¶¼¿ÉÒÔÓ¦ÓÃ(ÉõÖÁ¿ÉÒÔ¶Ôij¸ö ......