SQL Server ¾Ñé £¨×ªÔØ£©
http://www.cnblogs.com/treeyh/archive/2007/08/06/844763.html
Èç¹ûÄãÕýÔÚ¸ºÔðÒ»¸ö»ùÓÚSQL ServerµÄÏîÄ¿£¬»òÕßÄã¸Õ¸Õ½Ó´¥SQL Server£¬Ä㶼ÓпÉÄÜÒªÃæÁÙһЩÊý¾Ý¿âÐÔÄܵÄÎÊÌ⣬ÕâƪÎÄÕ»áΪÄãÌṩһЩÓÐÓõÄÖ¸µ¼£¨ÆäÖдó¶àÊýÒ²¿ÉÒÔÓÃÓÚÆäËüµÄDBMS£©¡£
ÔÚÕâÀÎÒ²»´òËã½éÉÜʹÓÃSQL ServerµÄÇÏÃÅ£¬Ò²²»ÄÜÌṩһ¸ö°üÖΰٲ¡µÄ·½°¸£¬ÎÒËù×öµÄÊÇ×ܽáһЩ¾Ñé----¹ØÓÚÈçºÎÐγÉÒ»¸öºÃµÄÉè¼Æ¡£ÕâЩ¾ÑéÀ´×ÔÎÒ¹ýÈ¥¼¸ÄêÖоÊܵĽÌѵ£¬Ò»Ö±À´£¬ÎÒ¿´µ½Ðí¶àͬÑùµÄÉè¼Æ´íÎó±»Ò»´ÎÓÖÒ»´ÎµÄÖظ´¡£ ¡¡
Ò»¡¢Á˽âÄãÓõŤ¾ß ¡¡¡¡
²»ÒªÇá
ÊÓÕâÒ»µã£¬ÕâÊÇÎÒÔÚÕâƪÎÄÕÂÖн²ÊöµÄ×î¹Ø¼üµÄÒ»Ìõ¡£Ò²ÐíÄãÒ²¿´µ½ÓкܶàµÄSQL Server³ÌÐòԱûÓÐÕÆÎÕÈ«²¿µÄT-SQLÃüÁîºÍSQL
ServerÌṩµÄÄÇЩÓÐÓõŤ¾ß¡£
¡¡¡¡“ʲô£¿ÎÒÒªÀË·ÑÒ»¸öÔµÄʱ¼äÀ´Ñ§Ï°ÄÇЩÎÒÓÀÔ¶Ò²²»»áÓõ½µÄSQLÃüÁ£¿£¿”£¬ÄãÒ²Ðí»áÕâÑù˵¡£¶ÔµÄ£¬Äã²»ÐèÒªÕâÑù×ö¡£µ«ÊÇÄãÓ¦¸ÃÓÃÒ»¸öÖÜÄ©ä¯ÀÀËù
ÓеÄT-SQLÃüÁî¡£ÔÚÕâÀÄãµÄÈÎÎñÊÇÁ˽⣬½«À´£¬µ±ÄãÉè¼ÆÒ»¸ö²éѯʱ£¬Äã»á¼ÇÆðÀ´£º“¶ÔÁË£¬ÕâÀïÓÐÒ»¸öÃüÁî¿ÉÒÔÍêȫʵÏÖÎÒÐèÒªµÄ¹¦ÄÜ”£¬ÓÚÊÇ£¬µ½
MSDN²é¿ ......
[Sql]EXCEPT ºÍ INTERSECT¹Ø¼ü×Ö
http://www.cnblogs.com/treeyh/archive/2008/07/01/1232845.html
EXCEPT
´Ó EXCEPT ²Ù×÷Êý×ó±ßµÄ²éѯÖзµ»ØÓұߵIJéѯδ·µ»ØµÄËùÓзÇÖظ´Öµ¡£
INTERSECT
·µ»Ø INTERSECT ²Ù×÷Êý×óÓÒÁ½±ßµÄÁ½¸ö²éѯ¾ù·µ»ØµÄËùÓзÇÖظ´Öµ¡£
A. ʹÓà EXCEPT
ÔÚʾÀýÖÐʹÓà TableA ºÍ TableB ÖеÄÊý¾Ý¡£
TableA (col1 int)
TableB (col1 int)
NULL
NULL
NULL
1
NULL
3
1
4
2
4
2
2
3
4
4
ÒÔϲéѯ´Ó EXCEPT
²Ù×÷Êý×ó²àµÄ²éѯ·µ»ØÓÒ²à²éѯûÓÐÕÒµ½µÄËùÓзÇÖظ´Öµ¡£
SELECT * from TableA EXCEPT
SELECT * from TableB;
ÏÂÃæÊǽá¹û¼¯£º
Col1
-----------
2
(1 row(s) affected)
B. ʹÓà INTERSECT
ÔÚʾÀýÖÐʹÓà TableA ºÍ TableB ÖеÄÊý¾Ý¡£
TableA (col1 int)
TableB (col1 int)
NULL
2
NULL
2
NULL
2
1
4
2
4
2
2
3
4
4
ÒÔϲéѯ·µ»Ø INTERSECT
²Ù×÷Êý×óÓÒÁ½²àµÄÁ½¸ö²éѯ¾ù·µ»ØµÄËùÓзÇÖظ´Öµ¡£
SELECT * from TableA INTERSECT ......
1£ºSQL ServerÊý¾Ý¿âÅäÖÃ
¿ªÆô·þÎñÆ÷
ÍÐÅÌÏÔʾ·þÎñÆ÷Æô¶¯
2:ÔÚStaAfx.h ÖÐÌí¼ÓÈçÏ´úÂë
#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF","adoEOF")rename("BOF","adoBOF")
//³öÏÖmsado15.dll ±íʾµ¼Èë³É¹¦
3:ÔÚBOOL CXXXApp::InitInstance()Öгõʼ»¯COM»·¾³
BOOL CXXXApp::InitInstance()
{
AfxEnableControlContainer();
::CoInitialize(NULL);
…….
ÊÍ·ÅCOM»·¾³
::CoUninitialize();
return FALSE;
}
4£ºËµÃ÷
ÀûÓÃϵͳĬÈ϶¨ÒåÈ«¾ÖCXXXAppÀàµÄ¶ÔÏótheApp¿ÉÒÔµ÷ÓÃÀà·½·¨£¨º¯Êý£©µÄÄÜÁ¦£¬
¹ÊÔÚCXXXAppÀàÖмÓÈëÁ¬½ÓÊý¾Ý¿âµÄ¹«¹²·½·¨—InitADOConn£¨£©ºÍ¹«¹²Êý¾Ý—
&nb ......
1£ºSQL ServerÊý¾Ý¿âÅäÖÃ
¿ªÆô·þÎñÆ÷
ÍÐÅÌÏÔʾ·þÎñÆ÷Æô¶¯
2:ÔÚStaAfx.h ÖÐÌí¼ÓÈçÏ´úÂë
#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF","adoEOF")rename("BOF","adoBOF")
//³öÏÖmsado15.dll ±íʾµ¼Èë³É¹¦
3:ÔÚBOOL CXXXApp::InitInstance()Öгõʼ»¯COM»·¾³
BOOL CXXXApp::InitInstance()
{
AfxEnableControlContainer();
::CoInitialize(NULL);
…….
ÊÍ·ÅCOM»·¾³
::CoUninitialize();
return FALSE;
}
4£ºËµÃ÷
ÀûÓÃϵͳĬÈ϶¨ÒåÈ«¾ÖCXXXAppÀàµÄ¶ÔÏótheApp¿ÉÒÔµ÷ÓÃÀà·½·¨£¨º¯Êý£©µÄÄÜÁ¦£¬
¹ÊÔÚCXXXAppÀàÖмÓÈëÁ¬½ÓÊý¾Ý¿âµÄ¹«¹²·½·¨—InitADOConn£¨£©ºÍ¹«¹²Êý¾Ý—
&nb ......
SQL:Structured Query Language,1974ÄêBoyceºÍChamberlinÌá³ö.
Êý¾Ý¶¨Òå :CREATE,DROP
Êý¾Ý¿â²éѯ:SELECT
Êý¾Ý²Ù×Ý :INSERT,UPDATE,DELETE
Êý¾Ý¿ØÖÆ :GRANT,REVOKE
Ò».Êý¾ÝµÄ¶¨ÒåºÍÐÞ¸Ä:
1.¶¨Òå»ù±í
CREATE TABLE ±íÃû (<ÁÐÃû1 ÀàÐÍ[NOT NULL][,ÁÐÃû2 ÀàÐÍ[NOT NULL]>…[ÆäËû²ÎÊý]);
¹ØÓÚÀàÐÍ:
INTEGER È«×Ö³¤µÄ¶þ½øÖÆÕûÊý.
SMALLINT °ë×Ö³¤µÄ¶þ½øÖÆÕûÊý.
DECIMAL(p[,q])ѹËõÊ®½øÖÆÊý,¹²pλСÊýµãºóÓÐqλ,15>=p>=q>=0,q=0ʱ¿ÉÊ¡ÂÔ.
FLOAT Ë«×Ö³¤µÄ¸¡µãÊý.
CHAR(n) ³¤¶ÈΪnµÄ¶¨³¤×Ö·û´®.
VARCHAR(n)±ä³¤×Ö·û´®,×î´ó³¤Îªn.
2.Ð޸Ļù±í
ALTER TABLE ±íÃû ADD ÁÐÃû ÀàÐÍ; //Ôö¼ÓÐÂÁÐ.
3.ɾ³ý»ù±í
DROP TABLE ±íÃû; //ɾ³ý»ù±íÁ¬Í¬±íÖмǼ.
¶þ.ÊÓͼµÄ¶¨Òå
1.¶¨ÒåÊÓͼ
CREATE VIEW ÊÓͼÃû[ÁÐÃû[,ÁÐÃû]…]AS ×Ó²éѯ[WITH CHECK OPTION];
2.ÊÓͼɾ³ý
DROP VIEW ÊÓͼÃû;
Èý.Êý¾Ý²Ù×Ý
SELECT [DISTINCT] Ñ¡ÔñÊä³öÊôÐÔ±í
from Òª¼ìË÷µÄ±íÃû
[WHERE ¼ìË÷Ó¦Âú×ãµÄÌõ¼þ]
[GROUP BY ·Ö×éÊôÐÔ±í(HAVING ¼ìË÷Ìõ¼þ)]
[ORDER BY ÅÅÐòÊôÐÔ±í];
1. ¼òµ¥²éѯ
(1).²»Ïû³ýÖظ´Ôª×éµÄ¼ìË÷
SELECT TITLE from BOOKS
(2).Ïû³ýÖظ´Ôª×éµÄ¼ìË ......
http://www.sql-server-performance.com/tips/clustered_indexes_p1.aspx
As a rule of thumb, every table should have a clustered index. Generally, but not always, the clustered index should be on a column that monotonically increases--such as an identity column, or some other column where the value is increasing--and is unique. In many cases, the primary key is the ideal column for a clustered index.
If you have any experience with performance tuning SQL Server 6.5, you may have heard that is not a good idea to add a clustered index to a column that monotonically increases because it can cause a "hotspot" on the disk that can cause performance problems. That advice is true in SQL Server 6.5.
Normally, "hotspots" aren't generally a problem. You would have to have over 1,000 transactions a second before a "hotspot" were to negatively affect performance. In fact, a "hotspot" can be beneficial under these circumstances because it eliminates page spli ......
ÎÒ¶¨ÒåÁËÒ»¸ö textarea:
<tr bgcolor="#CCCCCC" align="center" valign="bottom">
<td align="right" valign="top" class="style1" >ÎÄÕÂÄÚÈÝ£º</td>
<td width="83%" bgcolor="#FFFFFF" align="left">
<textarea cols="75" rows="6" style="width: 1000px; height: 576px"></textarea>
</td>
</tr>
<tr bgcolor="#abb8d6">
<td colspan="2" width="588" align="center" height="55">
& ......
×ܼǼÊý:4346; ×ÜÒ³Êý:725; ÿҳ6 Ìõ;
Ê×Ò³ ÉÏÒ»Ò³ [6] [7] [8] [9] 10
[11] [12] [13] [14] [15] ÏÂÒ»Ò³ βҳ