¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý
¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý--row_number() /rank()/dense_rank
Oracle·ÖÎöº¯ÊýRANK(),ROW_NUMBER(),LAG()µÈµÄʹÓ÷½·¨
ROW_NUMBER() OVER (PARTITION BY COL1 ORDER BY COL2)
±íʾ¸ù¾ÝCOL1·Ö×飬ÔÚ·Ö×éÄÚ²¿¸ù¾Ý COL2ÅÅÐò
¶øÕâ¸öÖµ¾Í±íʾÿ×éÄÚ²¿ÅÅÐòºóµÄ˳Ðò±àºÅ£¨×éÄÚÁ¬ÐøµÄΨһµÄ£©
RANK() ÀàËÆ£¬²»¹ýRANK ÅÅÐòµÄʱºò¸úÅÉÃû´ÎÒ»Ñù£¬¿ÉÒÔ²¢ÁÐ2¸öµÚÒ»ÃûÖ®ºó ÊǵÚ3Ãû
LAG ±íʾ ·Ö×éÅÅÐòºó £¬×éÄÚºóÃæÒ»Ìõ¼Ç¼¼õÇ°ÃæÒ»Ìõ¼Ç¼µÄ²î£¬µÚÒ»Ìõ¿É·µ»Ø NULL
BTW: EXPERT ONE ON ONE ÉϽ²µÄ×îÏêϸ,»¹ÓкܶàÏà¹ØÌØÐÔ£¬Îĵµ¿´ÆðÀ´±È½Ï·Ñ¾¢
row_number()ºÍrownum²î²»¶à£¬¹¦ÄܸüÇ¿Ò»µã£¨¿ÉÒÔÔÚ¸÷¸ö·Ö×éÄÚ´Ó1¿ªÊ±ÅÅÐò£©
rank()ÊÇÌøÔ¾ÅÅÐò£¬ÓÐÁ½¸öµÚ¶þÃûʱ½ÓÏÂÀ´¾ÍÊǵÚËÄÃû£¨Í¬ÑùÊÇÔÚ¸÷¸ö·Ö×éÄÚ£©
dense_rank()lÊÇÁ¬ÐøÅÅÐò£¬ÓÐÁ½¸öµÚ¶þÃûʱÈÔÈ»¸ú×ŵÚÈýÃû¡£
Ïà±ÈÖ®ÏÂrow_numberÊÇûÓÐÖظ´ÖµµÄ
lag£¨arg1,arg2,arg3):
arg1ÊÇ´ÓÆäËûÐзµ»ØµÄ±í´ïʽ
arg2ÊÇÏ£Íû¼ìË÷µÄµ±Ç°ÐзÖÇøµÄÆ«ÒÆÁ¿¡£ÊÇÒ»¸öÕýµÄÆ«ÒÆÁ¿£¬Ê±Ò»¸öÍù»Ø¼ìË÷ÒÔÇ°µÄÐеÄÊýÄ¿¡£
arg3ÊÇÔÚarg2±íʾµÄÊýÄ¿³¬³öÁË·Ö×éµÄ·¶Î§Ê±·µ»ØµÄÖµ¡£
ÓÐЩʱºòÎÒÃÇÏ£ÍûµÃµ½Ö¸¶¨Êý¾ÝÖеÄÇ°nÁУ¬Ê¾ÀýÈçÏ£º
µÃµ½Ã¿¸ö²¿ÃÅнˮ×î¸ßµÄÈý¸ö¹ÍÔ±£º
ÏÈ´´½¨Ê¾Àý±í
create table emp
as
select * from scott.emp;
alter table emp
add constraint emp_pk
primary key(empno);
create table dept
as
select * from scott.dept;
alter table dept
add constraint dept_pk
primary key(deptno);
ÏÈ¿´Ò»ÏÂrow_number() /rank()/dense_rank()Èý¸öº¯ÊýÖ®¼äµÄÇø±ð
select emp.deptno,emp.sal,emp.empno,row_number() over (partition by deptno order by sal desc) row_number, --1,2,3
rank() over (partition by deptno order by sal desc) rank, --1,1,3
dense_rank() over (partition by deptno order by sal desc) dense_rank from emp --1,1,2
½á¹ûÈçÏÂ:
10 5000.00 7839 1 &nbs
Ïà¹ØÎĵµ£º
Ò»¡¢SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
¡¡¡¡¡ð1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
¡¡¡¡¡ð2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ czdImport Dat ......
ת×Ô£ºhttp://www.orafaq.com/wiki/SQL*Loader_FAQ#How_can_one_get_SQL.2ALoader_to_COMMIT_only_at_the_end_of_the_load_file.3F
Contents
[hide
]
1
What is SQL*Loader and what is it used for?
2
How does one use the SQL*Loader utility?
3
How does one load MS-Excel data into Oracle?
4
Is ther ......
ËäȻֱ½Ó½«ÎļþÄÚÈÝ´æÈëÊý¾Ý¿â×ֶεÄÇé¿ö²»¶à£¬²»¹ýÔÚ¶ÔÓÚÎļþÄÚÈݻᷢÉú±ä»¯µÄÇé¿öÏ´æÈëÊý¾Ý¿â×Ö¶ÎÒ²²»Ê§ÎªÒ»ÖÖ·½·¨¡£
Æäʵ·½·¨ºÜ¼òµ¥£¬ÕâÀïÓõ½Ò»¸öload_fileº¯Êý£¬²»ÖªµÀÊDz»ÊÇÎÒϵÄMYSQLÊÖ²áÓÐÎÊÌâ¡£ÎÒÔÚÕÒÕâ¸öº¯ÊýµÄʱºòË÷ÒýºÍÄÚÈݲ»¶ÔÓ¦¡£
Ê×ÏÈÊǽ¨±íÓï¾ä
create table test (id int,file blob);
²åÈëÓï¾ ......
±È·½ËµÔÚ²éѯidÊÇ50µÄÊý¾Ýʱ£¬Èç¹ûÓû§´«½üÀ´µÄ²ÎÊýÊÇ50 and 1=1£¬Èç¹ûûÓÐÉèÖùýÂ˵Ļ°£¬¿ÉÒÔÖ±½Ó²é³öÀ´£¬SQL ×¢ÈëÒ»°ãÔÚASP³ÌÐòÖÐÓöµ½×î¶à£¬
¿´¿´ÏÂÃæµÄ
1.ÅжÏÊÇ·ñÓÐ×¢Èë
;and 1=1
;and 1=2
2.³õ²½ÅжÏÊÇ·ñÊÇmssql
;and user>0
3.ÅжÏÊý¾Ý¿âϵͳ
;and (select count(*) from sysobjects)>0 mssql ......