Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¡¾×ª¡¿oracleÐÐתÁÐͨÓùý³Ì

oracleÐÐתÁÐͨÓùý³Ì(ת)
»·¾³oracle 10g
¹¤×÷¹Øϵ,³£×öЩÐÐתÁб¨±í,±¨±íͨ³£²»ÊÇÔÚ´óÊý¾Ý¼¯ºÏÉÏ´¦Àí.
ËùÒÔдÁ˸ö¹ý³Ì.
±¾¹ý³Ì±È½ÏÊʺÏÔÚÓÚÐèÒª¶¯Ì¬Êä³ö±¨±íµÄµØ·½,ÀýÈçwebÖÐ.
²»ÊǺÜÍêÃÀ,µ«ÒѾ­¿ÉÒÔ½â¾ö¾ø´ó²¿·ÖµÄÎÊÌâ.
create or replace function func_RowToCol(
viewName Varchar2,
grpCols Varchar2,
colCol Varchar2,
valueCol Varchar2,
fillEmptyWithZero Number:=1,
rowOrder Varchar2:='',
colOrder Varchar2:='',
rowOrderinGrp Integer:=1,
colOrderStyle Varchar2:=' asc ',
fillValue Varchar2:=''
) return varchar2
Is
/*****************************************************************************************************
Ãû³Æ:func_RowToCol
²ÎÊý˵Ã÷:
viewName ÊÓͼÃû³Æ,ʵ¼ÊÉÏ¿ÉÒÔÊÇÊý¾Ý¿âµÄ±í¸ñÃû³Æ,ÊÓͼÃû³Æ,Ò²¿ÉÒÔÊÇSQLÓï¾ä.
grpCols ÐèÒª·Ö×éµÄÁÐ,ÒÔ¸ñʽ col1,col2..coln´«Èë,ÆäÖÐnÊÇ´óÓÚ0µÄÕûÊý
colCol ÓÉÐÐתΪÁеÄÄǸöÁÐ
valueCol ÐÐתÁкó,ÒÀÈ»×÷ΪֵÌî³äµÄÄǸöÁÐ,Ö»ÄÜÊÇÒ»¸öÁÐ
--viewIsSql ÊÓͼÊÇ·ñÊÇsqlÓï¾ä,Èç¹ûÊÇÔò´«Èë1,·´Ö®´«Èë2,ĬÈÏÊÇ1(ÊÇsql)
fillEmptyWithZero ÓÃ0À´Ìî³ä¿ÕÖµ,ĬÈÏ¿ÕÖµÒÀÈ»±£Áô¿ÕÖµ.Èç¹ûÊÇ1,ÔòÖ»¶ÔvalueColΪÊýÖµÀàÐ͵ÄÓÐЧ.
rowOrder ½á¹ûĬÈϵÄÅÅÐòÓï¾ä,Èç¹ûÓÐ,ÔòʹÓÃÕâ¸ö£¬Õâ¸öÊǶԽá¹ûµÄÐÐÅÅÐò
colOrder ¶Ôת³ÉµÄÁнøÐÐÅÅÐòµÄÒÀ¾Ý.
rowOrderinGrp ÐеÄÅÅÐòÁÐÊÇ·ñÔÚ·Ö×éÁУ¨grpcols)ÖУ¬0 ±íʾ²»ÊÇ£¬1±íʾÊÇ£¬Ä¬ÈÏÊÇÔÚ·Ö×éÁÐÖС£
colOrderStyle Õâ¸ö²ÎÊý˵Ã÷ÁËÁеÄÅÅÐò·½Ê½
fillValue Ìî³äÖµ£¬Èç¹û·Ç¿Õ,ÇÒfillEmptyWithZero=1£¬ÔòÓÃ.
¾ÙÀý:ÓÐÒ»¸ö±í¸ñEmpSalary(SalMonth number,EmpName varchar2(20),salary number) ÆäÖÐ
salMonth,EmpName×é³ÉΨһԼÊø
¼ÙÉèÓÐÒÔÏÂÊý¾Ý:
SALMONTH EMPNAME SALARY
---------- -------------------- ----------
200801 lzf 8000
200801 wth 8000
200801 lxl 7000
200801 fjl 8000
200801 wcl 40000
200802 lzf 9000
200802 wth 8000
....
ÏÖÔÚÐèÒª°´ÕÕÕâÑùµÄ¸ñʽÊä³ö
salaryMonth lzf wth lxl fjl wcl
200801 8000 8000 7000 8000 40000
200801 9000 8000
ÄÇô²ÎÊýÓ¦¸ÃÕâÑù´«µÝfunc_RowToCol('empsalary','','salarymonth','empname','salary',0,1);
Êä³ö:
Èç¹û³É¹¦,Ôò·µ»ØÒ»¸ö»ùÓÚtempdata_manycolsµÄ²éѯsql×Ö·û´®
Èç¹ûʧ°Ü,Ôò·µ»Ø¿ÕÖµ.
×¢ÒâÊÂÏî:
±¾º¯ÊýÊÇ»ùÓÚÒ»¸ö½Ðtempdata_manyCols


Ïà¹ØÎĵµ£º

oracle exp imp ³õ̽

Êý¾Ýµ¼³ö£º
 1 ½«Êý¾Ý¿âTESTÍêÈ«µ¼³ö,Óû§Ãûsystem ÃÜÂëmanager µ¼³öµ½D:\daochu.dmpÖÐ
   exp system/manager@TEST file=d:\daochu.dmp full=y
 2 ½«Êý¾Ý¿âÖÐsystemÓû§ÓësysÓû§µÄ±íµ¼³ö
   exp system/manager@TEST file=d:\daochu.dmp owner=(system,sys)
 3 ½«Êý¾Ý¿âÖеıíin ......

OracleÊý¾Ý¿âµÄÓÅ»¯Éè¼Æ

[ÕªÒª]Ö÷Òª´Ó´óÐÍÊý¾Ý¿âORACLE»·¾³Ëĸö²»Í¬¼¶±ðµÄµ÷Õû·ÖÎöÈëÊÖ£¬·ÖÎöORACLEµÄϵͳ½á¹¹ºÍ¹¤×÷»úÀí£¬´Ó²»Í¬·½Ãæ½ÏÈ«ÃæµØ×ܽáORACLEÊý¾Ý¿âµÄÓÅ»¯µ÷Õû·½°¸¡£
[¹Ø¼ü´Ê]ORACLEÊý¾Ý¿â¡¢»·¾³µ÷Õû¡¢ÓÅ»¯Éè¼Æ¡¢·½°¸
ÖÐͼ·ÖÀàºÅ£ºTP3 ÎÄÏ×±êʶÂ룺A ÎÄÕ±àºÅ£º1671£­7597(2008)0720043£­01
¡¡¡¡
¡¡¡¡ORACLEÊý¾Ý¿âÖÐÊý¾Ý´æÈ¡ÐÔÄ ......

28.4.1 ÊÖ¹¤Æô¶¯ºÍ¹Ø±ÕOracle·þÎñ

28.4.1  ÊÖ¹¤Æô¶¯ºÍ¹Ø±ÕOracle·þÎñ
OracleÊý¾Ý¿â·þÎñÓÉÁ½²¿·Ö×é³É£ºÊý¾Ý¿â½ø³ÌºÍÍøÂç¼àÌýÆ÷½ø³Ì£¬ËüÃÇ·Ö±ð¿Éͨ¹ýsqlplusºÍlsnrctlÃüÁî¿ØÖÆÆô¶¯¹Ø±Õ¡£
1£®Êý¾Ý¿â½ø³Ì
ʹÓÃDBCA¹¤¾ß´´½¨Êý¾Ý¿âºó£¬Æä½ø³ÌÒѾ­×Ô¶¯Æô¶¯£¬ÕâЩ½ø³Ì¶¼ÊÇÒÔÊý¾Ý¿âÃû³Æ£¨ÔÚ±¾ÀýÖÐΪorcl£©ÃüÃû£¬ÈçÏÂËùʾ¡£
 
$ ps -ef|grep orcl
orac ......

Oracle×ÔÔöIDʵÏÖ

Ê×ÏÈ£¬ÄãÒªÓÐÒ»ÕÅ±í£¡
       CREATE TABLE example(
             ID Number(4) NOT NULL PRIMARY KEY,
             NAME VARCHAR(25),
    ......

ORACLE ÐÐתÁÐ ²âÊÔͨ¹ý£¨9i£©

--ORACLE ÐÐתÁР ²âÊÔͨ¹ý£¨9i£©
/***************************************************************************************************
ÒÔѧÉú³É¼¨ÎªÀý×Ó£¬±È½ÏÐÎÏóÒ׶®
***********************************************************************************************************/
--1¡¢ÐÐתÁÐ
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ