sql»ù±¾Óï¾ä
/*********************************************************/
Ŀ¼Çåµ¥CONTEXT LIST
/*********************************************************/
1.Êý¾Ý¿âDataBase
1.1Êý¾Ý¿â½¨Á¢/ɾ³ýcreate/drop database
1.2Êý¾Ý¿â±¸·ÝÓë»Ö¸´backup/restore database
/*********************************************************/
2.Êý¾Ý²éѯDATA QUERY LANGUAGE
2.1Ñ¡Ôñ²éѯSelect Query
2.2¾Û¼¯²éѯAggregate Query
2.3×Ó²éѯ Sub Query
2.4Á¬½Ó²éѯTable Joins
2.5»ã×ܲéѯGroup Query
/*********************************************************/
3.Êý¾ÝÐÞ¸ÄDATA MODIFY LANGUAGE
3.1²åÈëÊý¾ÝInsert
3.2ÐÞ¸ÄÊý¾ÝUpdate
3.3ɾ³ýÊý¾ÝDelete
/*********************************************************/
4.Êý¾Ý¶¨ÒåDATA DEFINE LANGUAGE
4.1±íTable
4.2ÁÐColumn
4.3ÐòÁÐIdentity
4.4Ô¼ÊøConstraints
4.5Ë÷ÒýIndex
4.6ÊÓͼview
4.7ȨÏÞPrivilege
/*********************************************************/
5.Êý¾Ý¿âº¯ÊýFunctions
5.1ת»»º¯ÊýData Convert Functions
5.2¾Û¼¯º¯ÊýAggregate Functions
5.3×Ö·ûº¯Êýchar Functions
5.4ÈÕÆÚº¯ÊýDate Functions
5.5Êýѧº¯ÊýMath Functions
5.6·ÖÎöº¯ÊýAnalytical Functions
/*********************************************************/
6.Êý¾Ý¿â½Å±¾Script
6.1Êý¾ÝÀàÐÍData Types
6.2½Å±¾Óï·¨Statements
6.3½Å±¾ÓαêCursor
6.4´æ´¢¹ý³ÌProcedure
6.5´æ´¢º¯ÊýFunction
6.6´¥·¢Æ÷Trigger
6.7ÊÂÎñTransaction
6.8ÆäËüOther
/*********************************************************/
SQLÃ÷ϸ SQL DETAIL
/**********************************************************/
1.Êý¾Ý¿âDataBase
1.1Êý¾Ý¿â½¨Á¢/ɾ³ýcreate/drop database
1.2±¸·ÝÓë»Ö¸´backup/restore database
/**********************************************************/
1.1Êý¾Ý¿â½¨Á¢/ɾ³ýcreate/drop database
1.1.1.½¨Á¢Êý¾Ý¿â
Óï·¨:create database <Êý¾Ý¿âÃû> £ÛÆäËü²ÎÊý£Ý
´úÂë:
//½¨Á¢Êý¾Ý¿â hr
create database hr
1.1.2.ɾ³ýÊý¾Ý¿â¡£
Óï·¨:drop database <Êý¾Ý¿âÃû>
´úÂë:
//ɾ³ýÊý¾Ý¿âhr
drop database hr
//Èç¹û´æÔÚhrÊý¾Ý¿â,Ôòɾ³ýÊý¾
Ïà¹ØÎĵµ£º
ÎÄÕÂÀ´Ô´£ºIT¹¤³Ì¼¼ÊõÍø£¬ È«ÎÄÁ´½Ó£ºhttp://www.systhinker.com/html/81/n-11481.html
1.¼ÆËãÿ¸öÈ˵Ä×ܳɼ¨²¢ÅÅÃû
select name,sum(score) as allscore from stuscore group by name order by allscore
2.¼ÆËãÿ¸öÈ˵Ä×ܳɼ¨²¢ÅÅÃû
select distinct t1.name,t1.stuid,t2.allscore from stuscore t1,( select st ......
±¾ÎĽÚÑ¡×ÔMSDNµÄÎÄÕ¡¶ÎåÖÖÌá¸ß SQL ÐÔÄܵķ½·¨¡·£¬Ìá³öÈçºÎÌá¸ß»ùÓÚSQL ServerÓ¦ÓóÌÐòµÄÔËÐÐЧÂÊ£¬·Ç³£ÖµµÃÍƼö¡£¶ÔһЩTrafficºÜ¸ßµÄÓ¦ÓÃϵͳ¶øÑÔ£¬ÈçºÎÌá¸ßºÍ¸Ä½øSQLÖ¸ÁÊǷdz£ÖØÒªµÄ£¬Ò²ÊÇÒ»¸öºÜºÃµÄÍ»ÆƵ㡣
*ÎÄÕÂÖ÷Òª°üÀ¨ÈçÏÂһЩÄÚÈÝ£¨Èç¸ÐÐËȤ£¬ÇëÖ±½Ó·ÃÎÊÏÂÃæµÄURLÔĶÁÍêÕûµÄÖÐÓ¢ÎÄÎĵµ£©£º
1, ´Ó INSERT ·µ ......
[code=SQL][/code]
--Óï ¾ä ¹¦ ÄÜ
--Êý¾Ý²Ù×÷
SELECT --´ÓÊý¾Ý¿â±íÖмìË÷Êý¾ÝÐкÍÁÐ
INSERT --ÏòÊý¾Ý¿â±íÌí¼ÓÐÂÊý¾ÝÐÐ
DELETE --´ÓÊý¾Ý¿â±íÖÐɾ³ýÊý¾ÝÐÐ
UPDATE --¸üÐÂÊý¾Ý¿â±íÖеÄÊý¾Ý
--Êý¾Ý¶¨Òå
CREATE TABLE --´´½¨Ò»¸öÊý¾Ý¿â±í
DROP TABLE --´ÓÊý¾Ý ......
(1)Êý¾Ý¼Ç¼ɸѡ£º
sql="select*fromÊý¾Ý±íwhere×Ö¶ÎÃû=×Ö¶ÎÖµorderby×Ö¶ÎÃû[desc]"
sql="select*fromÊý¾Ý±íwhere×Ö¶ÎÃûlike'%×Ö¶ÎÖµ%'orderby×Ö¶ÎÃû[desc]"
sql="selecttop10*fromÊý¾Ý±íwhere×Ö¶ÎÃûorderby×Ö¶ÎÃû[desc]"
sql="select*fromÊý¾Ý±íwhere×Ö¶ÎÃûin('Öµ1','Öµ2','Öµ3')"
sql="select*fromÊý¾Ý±íwhere× ......
¡ô1.DBCC CacheStats £ºÏÔʾ´æÔÚÓÚµ±Ç° buffer Cache ÖеĶÔÏóµÄÐÅÏ¢£¬ÀýÈç £ºhitrates ±àÒëµÄ¶ÔÏóºÍÖ´Ðмƻ®
DBCC CACHESTATS
¡¡¡¡´ÓÕâ¸öÃüÁî¿ÉÒԵõ½Ò»Ð©¹Ø¼üµÄͳ¼ÆÐÅÏ¢£º
¡¡¡¡Hit Ratio£ºÏÔʾÌض¨¶ÔÏó¿ÉÒÔÔÚSql ServerµÄ»º´æÖб»ÃüÖеİٷֱȣ¬Õâ¸öÊýÖµÔ½´ó£¬Ô½ºÃ
¡¡¡¡Object Count£ºÏÔ ......