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

Sql Server 2005 row_number()·ÖÒ³ÐÔÄܲâÊÔ

  ÏÖÔÚ·ÖÒ³·½·¨´ó¶à¼¯ÖÐÔÚselect top/not in/Óαê/row_number£¬¶øselect top·ÖÒ³(ÔÚÕâ»ù´¡ÉÏ»¹Óжþ·Ö·¨)·½·¨Ëƺõ¸üÊÜ´ó¼Ò»¶Ó­£¬ÕâƪÎÄÕ²¢²»´òËãÈ¥ÌÖÂÛÊÇ·ñͨÓõÄÎÊÌ⣬±¾×ÅʵÓõÄÔ­Ôò£¬»¨ÁËһЩʱ¼äÈ¥²âÊÔrow_number()·ÖÒ³µÄÐÔÄÜ£¬¸Ð¾õ²¢²»ÏñÒ»²¿·ÖÈËËù˵µÄÄÇô¼¦Àߣ¬ÓÉÓÚ½Ó´¥Èí¼þ¿ª·¢²ÅÊ®¸öÔ£¬·½·½ÃæÃæµÄ¶«Î÷¶¼ÒªÑ§£¬¾­ÑéʵÔÚÓÐÏÞ,²»×ãÖ®´¦ÇëÔ­Á£¬²âÊÔÈçÏ£º
ƽ̨Óë»·¾³£º
CPU:AMD 1150 2G µ¥ºË
Äڴ棺1G(ϵͳÕý³£Æô¶¯ºóÔ¼Õ¼300M¿Õ¼ä)
Ó²ÅÌ£ºSATA 160G 8M Cache
ϵͳ£ºwindows 2003 ent+Sql Server 2005 sp2
Êý¾Ý£º¹²500ÍòÌõ
-------------------------------------------------------------------
²âÊÔÊý¾Ý£º
create table test_table
(
id   int identity(1,1) primary key not null,
cid   int  not null,
userName  varchar(50) null,
userPwd   varchar(50) null,
createTime datetime null
)
---------------------------------------------------------------------
²åÈë¼Ç¼(cid·Ö±ð²åÈë1,2,3,4,»úÆ÷ʵÔÚÌ«Âý,×ܹ²Ö»²åÈë500ÍòÌõ)£º
declare @count int
set @count=1
while @count<=1000000
begin
insert into test_table(cid,userName,userPwd,createTime) values(2,'admin','admin888',getdate())
set @count=@count+1
end
-------------------------------------------------------------------------------------------------------
·ÖÒ³²âÊÔ´úÂ룺
ÕâÀï²ÉÓÃrow_numberµÄÁ½ÖÖ·ÖÒ³·½Ê½£º·Ö±ðÓÃtopºÍbetween¹ýÂË
/*row_number() ²éѯ·½·¨Ò»*/
declare @tdiff datetime
set @tdiff=getdate()
select top 20 * from(select row_number() over(order by createtime desc,id asc) as rownumber,* from test_table ) as tb where rownumber>120000
select datediff(ms,@tdiff,getdate()) as 'ºÄʱ(ºÁÃë)'
/*row_number() ²éѯ·½·¨¶þ*/
declare @tdiff datetime 
set @tdiff=getdate()
select * from(select row_number() over(order by createtime desc,id asc) as rownumber,* from test_table ) as tb where rownumber between 120000 and 120200
select datediff(ms,@tdiff,getdate()) as 'ºÄʱ(ºÁÃë)'
----------------------------------------------------------------------------------------------------------
²âÊÔ·½·¨¼°½á¹û(È¡


Ïà¹ØÎĵµ£º

º½¿Õ¹«Ë¾¹ÜÀíϵͳ(VC++ ÓëSQL 2005)

ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
      ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......

SQLÓï¾äÊÕ¼¯

Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
4¡¢Ëµ ......

sql ÈÕÖ¾¹ÜÀí


Çå³ý SQL SERVER 2005 ÊÂÎñÈÕÖ¾
£±.ÓÒ¼üÔÚÇå³ýÈÕÖ¾µÄÊý¾Ý¿â£¬Èç“TestDB”£¬µã»÷[н¨²éѯ£¨Q£©]
£².ÊäÈëÒÔÏÂSQLÓï¾ä£¬ÆäÖГTestDB”ÊÇÊý¾Ý¿âÃû³Æ
DUMP TRANSACTION TestDB WITH NO_LOG
£³.Ö´ÐиÃSQL£¬³É¹¦ºó¼ÌÐøÒÔϲÙ×÷
£´.ÓÒ¼ü¸ÃÊý¾Ý¿â½Úµã£¬µã»÷[ÈÎÎñ£¨T£©] -> [ÊÕËõ£¨S£©] -> [Îļþ ......

SQL Server Ë÷Òý½á¹¹¼°ÆäʹÓã¨Èý£©

ʵÏÖСÊý¾ÝÁ¿ºÍº£Á¿Êý¾ÝµÄͨÓ÷ÖÒ³ÏÔʾ´æ´¢¹ý³Ì
¡¡¡¡½¨Á¢Ò»¸ö Web Ó¦Ó㬷ÖÒ³ä¯ÀÀ¹¦Äܱز»¿ÉÉÙ¡£Õâ¸öÎÊÌâÊÇÊý¾Ý¿â´¦ÀíÖÐÊ®·Ö³£¼ûµÄÎÊÌâ¡£¾­µäµÄÊý¾Ý·ÖÒ³·½·¨ÊÇ:ADO ¼Í¼¼¯·ÖÒ³·¨£¬Ò²¾ÍÊÇÀûÓÃADO×Ô´øµÄ·ÖÒ³¹¦ÄÜ£¨ÀûÓÃÓα꣩À´ÊµÏÖ·ÖÒ³¡£µ«ÕâÖÖ·ÖÒ³·½·¨½öÊÊÓÃÓÚ½ÏСÊý¾ÝÁ¿µÄÇéÐΣ¬ÒòΪÓα걾ÉíÓÐȱµã£ºÓαêÊÇ´æ·ÅÔÚÄÚ´æÖУ¬º ......

PL/SQLÀý×Ó

ÒÔÏÂÊǾ­²âÑéÄÜÕýÈ·ÔËÐеÄ:
create    table t_emp_log212
(
who varchar2(10) not null,
action varchar2(10) not null,
actime date
);
create or replace trigger tri_emp_insert
before insert
on t_emp
begin
insert into t_emp_log(who,action,actime)values(user,'insert',sysdate);
end ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ