SQL server µÚÈýƪ ¶à±íÁª½Ó²éѯ
¶à±íÁª½Ó²éѯ
Ò»¡¢¶à±íÁª½Ó²éѯµÄ·ÖÀà
¶à±íÁª½Ó²éѯʵ¼ÊÉÏÊÇͨ¹ý¸÷¸ö±íÖ®¼ä¹²Í¬ÁеĹØÁªÐÔÀ´²éѯÊý¾ÝµÄ£¬ËüÊǹØϵÊý¾Ý¿â²éѯ×îÖ÷ÒªµÄÌØÕ÷¡£
Áª½Ó²éѯ¿É·ÖΪÈý´óÀ࣬·ÖÁíΪ£º
1£® ÄÚÁª½Ó¡£
2£® ÍâÁª½Ó¡£
3£® ½»²æÁª½Ó¡£
ÄÇôÎÒÃÇÒ»ÆðÀ´¿´Ò»ÏÂÈçºÎʹÓöà±íÁª½Ó²éѯ¡£
A. ÄÚÁª½Ó£ºÄÚÁª½ÓÊÇ×îµäÐÍ¡¢×î³£ÓõÄÁª½Ó²éѯ£¬Ëü¸ù¾Ý±íÖй²Í¬µÄÁÐÀ´½øÐÐÆ¥Å䣬ֻÓÐÂú×ãÆ¥ÅäµÄÌõ¼þµÄÊý¾Ý²ÅÄܱ»²éѯ³öÀ´¡£Í¨³££¬Á½¸ö±í´æÔÚÖ÷Íâ¼ü¹Øϵʱ»áʹÓõ½ÄÚÁª½Ó²éѯ¡£
ÄÚÁª½á³£Ê¹ÓÓ=”±È½ÏÔËËã·ûÀ´ÅжÏÁ½ÁÐÊý¾ÝÊÇ·ñÏàµÈ£¬ÔÚÕâÀïÎÒÃÇͨ¹ý¼¸¸öʵÀýÀ´Ñ§Ï°ÄÚÁª½Ó²éѯ¡£
a) ÏÈÔÚSQL Server 2005ÖÐн¨Á½¸ö±íusersTableºÍusersNote,Á½±íµÄÄÚÈÝÈçÏÂÃæµÄͼÖÐËùʾ¡£
±íusersTable
±íusersNote
b) ÔÚ½¨ºÃÏàÓ¦µÄ±íºó£¬ÎÒÃǾͿÉÒÔ½øÐжà±í²éѯÁË£¬Ê×ÏÈÄÚÁª½ÓÎÒÃÇÓÐÁ½ÖÖ·½Ê½À´²éѯ¡£
µÚÒ»ÖÖ£ºÖ±½ÓÔÚWhereÌõ¼þÀïͨ¹ý±í´ïʽÀ´½øÐбíÖ®¼äµÄ¹ØÁª¡£
select usersTable.myuser,usersTable.mypwd,
usersNote.useraddress,userphonenumber
--²éѯÏÔʾdbo.usersTableºÍdbo.usersNote±íÖеÄÖ¸¶¨µÄÄÚÈÝ
from dbo.usersTable,dbo.usersNote
--ÄÚÁª½ÓÁ½±í
where usersTable.myuser=usersNote.username
--Á½±íÆ¥ÅäµÄÌõ¼þ
ÔÚSQL 2005ÖеIJéѯ½á¹ûÈçÏ£º
µÚ¶þÖÖ£ºÍ¨¹ýʹÓÃInner Join¹Ø¼ü×Ö½øÐбíÖ®¼äµÄ¹ØÁª¡£
select usersTable.myuser,usersTable.mypwd,
usersNote.useraddress,userphonenumber
from dbo.usersTable inner join dbo.usersNote
on (usersTable.myuser=usersNote.username)
²éѯ½á¹ûÈçÏ£º
B. ÍâÁª½Ó£ºÍâÁª½ÓÓÖ¿É·ÖΪ×óÍâÁª½Ó¡¢ÓÒÍâÁª½Ó¡¢ÍêÕûÁª½ÓÈýÖÖ¡£
ÍâÁª½ÓÓëÄÚÁª½ÓÇø±ðÔÚÓÚ£¬²»½öÏÔʾÁ½¸ö±í¹ØÁª×Ö¶ÎÆ¥ÅäµÄ¼Ç¼£¬Í¬Ê±²»Æ¥Åä¼Ç¼¸ù¾ÝÍâÁª½ÓÀàÐÍÒ²»áÏÔʾ¡£
a) ×óÍâÁª½Ó£ºLeft Join »ò Left Outer Join¡£
×óÍâÁª½ÓµÄ½á¹û¼¯°üÀ¨Left Join×Ó¾äÖÐÖ¸¶¨µÄ×ó±íµÄËùÓÐÐУ¬¶ø²»½ö½öÊÇÁª½ÓÁÐËùÆ¥ÅäµÄÐС£Èç¹û
Ïà¹ØÎĵµ£º
sql Ìí¼ÓзÖÇø
ALTER PARTITION SCHEME SCH_Source_ID_DT_ID
NEXT USED sn3
go
ALTER PARTITION FUNCTION [PF_Source_ID_DT_ID]()
SPLIT RANGE ('350000')
ɾ³ý·ÖÇø
±à¼
ALTER PARTITION FUNCTION [PF_Source_ID_DT_ID]( ......
Ëø»úÖÆ
NOLOCKºÍREADPASTµÄÇø±ð¡£
1. ¿ªÆôÒ»¸öÊÂÎñÖ´ÐвåÈëÊý¾ÝµÄ²Ù×÷¡£
BEGIN TRAN t
INSERT INTO Customer
SELECT 'a','a'
2. Ö´ÐÐÒ»Ìõ²éѯÓï¾ä¡£
SELECT * from Customer WITH (NOLOCK)
½á¹ûÖÐÏÔʾ"a"ºÍ"a"¡£µ±1ÖÐÊÂÎñ»Ø¹öºó£¬ÄÇôa½«³ÉΪÔàÊý¾Ý¡£(×¢:1ÖеÄÊÂÎñδÌá½») ¡£NOLOCK±íÃ÷ûÓжÔÊý¾Ý±íÌí¼Ó¹²Ï ......
sql server³öÏÖÑ¡¶¨µÄÓû§ÓµÓжÔÏó¶øÎÞ·¨É¾³ýµÄ´¦Àí
2006-4-5 19:50:00
·½·¨Ò»
Ê×ÏÈÄãÐèÒª×öµÄµÚÒ»¼þÊÂ
ÆóÒµ¹ÜÀíÆ÷-¡µÑ¡Ôñ·þÎñÆ÷-¡µÊô***-¡µ·þÎñÆ÷ÉèÖÃ-¡µÌôÉÏÔÊÐí¶ÔϵͳĿ¼¡£¡£¡£-¡µÈ·¶¨
µÚ¶þ²½
ÕÒµ½ÄãµÄÊý¾Ý¿âÕÒµ½sysusers±íÄÇÄãÒÔÇ°µÄÓû§É¾³ý
µÚÈý²½»ØÈ¥°ÉÊô***Öµ¸Ä»ØÀ´
µÚËIJ¿Öؽ¨Óû§¼´¿É
·½·¨¶þ
¶ ......
×÷Õߣºsuperhasty
2007-11-29
ÔÚÂÛ̳Éϳ£¼ûÓÐÅóÓѱ§Ô¹£¬ËµSQL ServerÌ«³ÔÄÚ´æÁË¡£ÕâÀï±ÊÕ߸ù¾Ý¾Ñé¼òµ¥½éÉÜÒ»ÏÂÄÚ´æÏà¹ØµÄµ÷ÓÅ֪ʶ¡£Ê×ÏÈ˵Ã÷Ò»ÏÂSQL
ServerÄÚ´æÕ¼ÓÃÓÉÄļ¸²¿·Ö×é³É¡£SQL ServerÕ¼ÓõÄÄÚ´æÖ÷ÒªÓÉÈý²¿·Ö×é³É£ºÊý¾Ý»º´æ(Data
Buffer)¡¢Ö´Ðлº´æ(Procedure Cache)¡¢ÒÔ¼°SQL ServerÒýÇæ³ÌÐò¡£S ......