sqlÊä³ö9*9³Ë·¨¿Ú¾÷±í
--------------·½·¨A-----------------
³ÌÐò:
declare
i int:=1;
v varchar2(200):=NULL;
v1 varchar2(20):=NULL;
begin
loop
for k in 1..i loop
v1:=k||'*'||i||'='||k*i;
v:=v||' '||v1;
end loop;
dbms_output.put_line(v);
v:=NULL;
i:=i+1;
exit when i>9;
end loop;
end;
ÔËÐнá¹ûÈçÏÂ:
1*1=1
1*2=2 2*2=4
1*3=3 2*3=6 3*3=9
1*4=4 2*4=8 3*4=12 4*4=16
1*5=5 2*5=10 3*5=15 4*5=20 5*5=25
1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36
1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49
1*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64
1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81
--------------·½·¨B--------Åå·þ¸Ã×÷Õߵļ¼Êõ---------
select max(sys_connect_by_path(st, ' '))
from (select i || '*' || j || '=' || i * j st, i, j
from (select rownum i from dual connect by rownum < 10) a,
(select rownum j from dual connect by rownum < 10) b
where i <= j)
connect by j = prior j and i = prior i + 1
start with i = 1
group by j
order by 1
MAX(SYS_CONNECT_BY_PATH(ST,''))
-----------------------------------------------------------------------------------
1*1=1
1*2=2 2*2=4
1*3=3 2*3=6 3*3=9
Ïà¹ØÎĵµ£º
½ñÌìÓöµ½Ò»¸öÎÊÌ⣺
ÔÚÆ´Ò»Ìõ¶¯Ì¬SqlÓï¾äʱ£¬ÓÉÓÚÊÇÓÃ×ֶεÄÖµ×öÁÐÃû£¬ËùÒÔÁÐÃûÓõ½Á˺º×Ö¡£
Ò»ÔËÐУ¬±¨´í£ºÔÚ“¡¢”¸½¼þÓÐÓï·¨´íÎó¡£
ºÜÄÉÃÆ£¬ÄѵÀ³¬³¤ÁË£¿
³¢ÊÔÔÚÆóÒµ¹ÜÀíÆ÷ÖÐÌí¼ÓÕâ¸öÁÐÃû£¬·¢ÏÖÌí¼ÓÍêÖ®ºóϵͳ×Ô¶¯Ìí¼ÓÁËÒ»¶ÔÖÐÀ¨ºÅ£¬¶ÔÓÚ"aa¡¢bb","aa£¬bb"Ò²¶¼Ìí¼ÓÁËÖÐÀ¨ºÅ¡£
¿´À´ÊÇ΢ÈíΪÁËÒÔ·ÀÍòÒ»£¬Á¬ ......
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"."- ......
±¾ÏµÁÐÎÄÕµ¼º½
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Ò»)--sum()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(¶þ)--max()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Èý)--row_number() /rank()/dense_rank()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(ËÄ)--lag()/lead()
ÓÐʱºò±¨±íÉÏÃæÐèÒªÏÔʾ¸Ã±Ê²Ù×÷µÄÉÏÒ»²½Öè»òÕßÏÂÒ»²½ÖèµÄÏêϸÐÅÏ¢£¬Õâ¸öʱºò¿ ......
----start
·²ÊÇÖªµÀÊý¾Ý¿âµÄÈ˶¼ÖªµÀSQL£¬·²ÊǶÔSQLÓÐÒ»µãÁ˽âµÄÈ˶¼¾õµÃSQLºÜ¼òµ¥£¬·²ÊÇÓÐÕâÖָоõµÄÈ˶¼ÊÇSQLµÃ³õ¼¶Óû§£¬ÒòΪËûѧ»áÁËÔö²éɾ¸Ä¾ÍÒÔΪÕâ¾ÍÊÇSQLµÄÈ«²¿¡£Ä¿Ç°µÄ´ó²¿·ÖÓ¦ÓÃÈí¼þ¶¼ÊÇÒÔÊý¾Ý¿âΪÖÐÐÄ£¬Ëæ×ÅÈí¼þµÄÔËÐУ¬Êý¾ÝÁ¿»áÔ½À´Ô½´ó¡£ÈçºÎÓüò½à¡¢¸ßЧµÄSQLÓï¾ä²Ù×÷Êý¾ÝÏÔµÃÔ½À ......
1¡¢Ñ»·²åÈë²âÊÔÊý¾Ý£º
SQL>
declare
maxrecords constant int:=100;
i int :=1;
Begin
for i in 1..maxrecords loop
--²åÈëÊý¾Ý
Insert into TEST.EXAMPLE(name,phone,address) values('·ÖÒ³²âÊÔÊý¾Ý....','ÁªÏµµç»°','ÁªÏµµØÖ·');
end loop;
commit;
end;
´Ë´¦EXAMPLE±í¶¨ÒåΪ(ID number,name ......