[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(¶þ)
±¾ÏµÁÐÎÄÕµ¼º½
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Ò»)--αÁÐROWNUMʹÓü¼ÇÉ
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(¶þ)--±êÁ¿×Ó²éѯ
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Èý)--PackageµÄÓŵã
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(ËÄ)--ÅúÁ¿´¦Àí
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Îå)--µ÷Óô洢¹ý³Ì·µ»Ø½á¹û¼¯
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Áù)--%ROWTYPEµÄʹÓÃ
±êÁ¿×Ó²éѯ
ORACLEÔÊÐíÔÚselect×Ó¾äÖаüº¬µ¥ÐÐ×Ó²éѯ, ʹÓñêÁ¿×Ó²éѯ¿ÉÒÔÓÐЧµÄ¸ÄÉÆÐÔÄÜ£¬µ±Ê¹Óõ½ÍⲿÁ¬½Ó£¬»òÕßʹÓõ½Á˾ۺϺ¯Êý£¬¾Í¿ÉÒÔ¿¼ÂDZêÁ¿×Ó²éѯµÄ¿ÉÄÜÐÔ
1. È¡ÏûÍⲿÁ¬½ÓµÄʹÓÃ
ÍⲿÁ¬½ÓµÄ×ö·¨£º
select a.username,count(*) from all_users a,all_objects b
where a.username=b.owner(+)
group by a.username;
¸Ä³É±êÁ¿×Ó²éѯµÄ×ö·¨£º
select a.username,(select count(*) from all_objects b where b.owner=a.username) cnt
from all_users a;
PS: Á½ÖÖ×ö·¨µÃµ½µÄ½á¹û»áÓÐЩÐí²î±ð£¬Ö÷ÒªÔÚall_objectsûÓзûºÏÌõ¼þµÄÐÐʱ, ÍⲿÁ¬½ÓµÄcount(*)=1£¬¶ø±êÁ¿×Ó²éѯµÄcount(*)½á¹û=0
select a.username,count(*),avg(object_id) from all_users a,all_objects b
where a.username=b.owner(+)
group by a.username;
2. ¶à¸ö¾ÛºÏº¯ÊýµÄʹÓü¼ÇÉ
µ±Í¬Ê±³öÏÖcount(*)/avg()ʱ£¬²»ÊʺÏÔÚselect×Ó¾äÖе÷ÓÃÁ½´Î×Ó²éѯ£¬ÐÔÄÜÉÏ»áÊܵ½Ó°Ïì, ¿ÉÒÔ¸ÄÓÃÏÂÃæÁ½ÖÖ×ö·¨
(1).Æ´½ÓÖ®ºóÔÙ²ð·Ö
select username,to_number(substr(data,1,10)) cnt,to_number(substr(data,11)) avg from
(
select a.username,(select to_char(count(*),'fm0000000009') || avg(object_id) from all_objects b where b.owner=a.username) data
from all_users a
)
(2).´´½¨¶ÔÏóÀàÐÍ
create or replace type myType as object
(cnt number,avg number);
select username,a.data.cnt,a.data.avg from
(
select username,(select myType(count(*),avg(object_id)) from all_objects b where b.owner=a.username) data
from all_users a
) 
Ïà¹ØÎĵµ£º
1.ÔÚ²éѯ·ÖÎöÆ÷ϲéѯExcelÎĵµ
Select * from
OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source = "c:\²âÊÔ.xls";User ID = Admin;Password=;Extended properties=Excel8.0)....Sheet1$
2.´ÓÊý¾Ý¿âÖе¼³öÊý¾Ý²¢´æµ½ÎļþÖÐ
EXEC master..xp_cmdshell 'bcp CAS2004..HGZ_LIAOJIAN out c:\temp1.xls -c -q -S"."- ......
½ñÌìÎÒÃÇ¿ªÊ¼SQL SERVER BIµÄÁíÍâÒ»¸öÖØÒªµÄ²¿·Ö --Reporting Service£¬Ïà¶ÔÓÚIntegration ServiceºÍAnalysis Service£¬Reporing ServiceÔÚ¹úÄÚµÄʹÓÃÕßÓ¦¸Ã¶àºÜ¶à.Ò»·½ÃæÓÉÓÚReporing Service·ÑÓñȽϵͣ¬Ö±½Ó¸½ÊôÔÚSQL SERVERÖУ¬ÁíÍâÒ»·½ÃæÆäʵSSRSÔںܴó³Ì¶ÈÉÏ»¹ÊÇÂú×ãÎÒÃǵı¨±íÐèÇóµÄ¡£ ÔÚSQL Server 2008ÖУ¬ ......
ÔÚʹÓÃODP.NET½øÐÐOracle±à³Ìʱ£¬ÓÐʱºòSQLÓï¾ä·Ç³£¸´ÔÓ£¬ÐèÒª²ÉÓö¯Ì¬¹¹Ôì²éѯÓï¾äµÄÇé¿ö£¬ÓÐÁ½ÖÖ·½·¨¿ÉÒÔ¹¹Ô춯̬µÄSQLÓï¾ä£¬²¢Ö´Ðзµ»Ø½á¹û¼¯¡£
1¡¢ÔÚÊý¾Ý·ÃÎʲ㹹ÔìSQLÓï¾ä
ÀýÈçÏÂÃæµÄÓï¾ä£¬½«¹¹ÔìÍêÕûµÄSQLÓï¾ä¸³Öµ¸øCommandText£¬ÔÙ´«µÝµ½Êý¾Ý¿â½øÐÐÖ´ÐУ¬·µ»Ø½á¹û¼¯¡£
loadCommand.CommandType = Com ......
±¾ÏµÁÐÎÄÕµ¼º½
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Ò»)--sum()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(¶þ)--max()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Èý)--row_number() /rank()/dense_rank()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(ËÄ)--lag()/lead()
Èç¹ûÎÒÃÇ°´ÕÕʾÀýÏëµÃµ½Ã¿¸ö²¿ÃÅнˮֵ×î¸ßµÄ¹ÍÔ±µÄ¼Í¼£¬¿ÉÒÔÓÐËÄÖÖ·½·¨ÊµÏÖ£ ......
±¾ÏµÁÐÎÄÕµ¼º½
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Ò»)--αÁÐROWNUMʹÓü¼ÇÉ
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(¶þ)--±êÁ¿×Ó²éѯ
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Èý)--PackageµÄÓŵã
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(ËÄ)--ÅúÁ¿´¦Àí
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Îå)--µ÷Óô洢¹ý³Ì·µ»Ø½á¹û¼¯
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Áù)- ......