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

SQL Server Óï¾ä

1.SELECTÓï¾ä´ÓÊý¾Ý¿âÖÐÑ¡È¡Êý¾Ý
SELECT 'ÁÐÃû' from '±íÃû' SELECT list_name from table_name ´Ó '±íÃû' Ñ¡Çø'ÁÐÃû' Êý¾Ý SQL SELECT * from table_name ´Ó '±íÃû' Ñ¡ÇøÈ«²¿Êý¾Ý
2.SELECT ¼ÓWHERE Óï¾ä
SELECT 'ÁÐÃû' from '±íÃû' WHERE 'Ìõ¼þ'
3.SELECT ¼ÓAS Óï¾ä
ʹÓÃAS ¸øÊý¾ÝÖ¸¶¨Ò»¸ö±ðÃû¡£´Ë±ðÃûÓÃÀ´ÔÚ±í´ïʽÖÐʹÓà count()º¯ÊýµÄ×÷ÓÃÊÇ£º¼ÆËãÊý×éÖеÄÔªËØÊýÄ¿»ò¶ÔÏóÖеÄÊôÐÔ¸öÊý¡£ SELECT CONCAT(*) AS new_name
4.SELECT JOIN ONÓï¾ä
JOINÁªºÏ²Ù×÷Á½¸ö±í SELECT 'ÁÐÃû1' 'ÁÐÃû2' from '±íÃû1' JOIN '±íÃû2' ON Ìõ¼þ SELECT A.SYMBOL,A.SNAME from SECURITYCODE A JOIN DAYQUOTE B ON A.SYMBOL =B.SYMBOL SQL--JOINÖ®ÍêÈ«Ó÷¨(°æ±¾2)
5.SELECT ORDER BYÓï¾ä
ORDER BYÅÅÐòASCÉýÐò, DESC½µÐò SELECT 'ÁÐÃû' from '±íÃû1' ORDER BY 'ÁÐÃû' [ASC, DESC] SELECT list_name from table_name Orders ORDER BY list_name
6.SELECT LIMITÓï¾ä
SELECT * from table LIMIT [offset,] rows | rows OFFSET offset LIMIT ·µ»ØÖ¸¶¨µÄ¼Ç¼Êý¡£LIMIT ½ÓÊÜÒ»¸ö»òÁ½¸öÊý×Ö²ÎÊý¡£²ÎÊý±ØÐëÊÇÒ»¸öÕûÊý³£Á¿¡£Èç¹û¸ø¶¨Á½¸ö²ÎÊý£¬µÚÒ»¸ö²ÎÊýÖ¸¶¨µÚÒ»¸ö·µ»Ø¼Ç¼ÐеÄÆ«ÒÆÁ¿£¬µÚ¶þ¸ö²ÎÊýÖ¸¶¨·µ»Ø¼Ç¼ÐеÄ×î´óÊýÄ¿¡£³õʼ¼Ç¼ÐеÄÆ«ÒÆÁ¿ÊÇ 0(¶ø²»ÊÇ 1)£º SELECT * from table LIMIT 5,10; // ¼ìË÷¼Ç¼ÐÐ 6-15 //ΪÁ˼ìË÷´Óijһ¸öÆ«ÒÆÁ¿µ½¼Ç¼¼¯µÄ½áÊøËùÓеļǼÐУ¬¿ÉÒÔÖ¸¶¨µÚ¶þ¸ö²ÎÊýΪ -1£º SELECT * from table LIMIT 95,-1; // ¼ìË÷¼Ç¼ÐÐ 96-last. //Èç¹ûÖ»¸ø¶¨Ò»¸ö²ÎÊý£¬Ëü±íʾ·µ»Ø×î´óµÄ¼Ç¼ÐÐÊýÄ¿£º SELECT * from table LIMIT 5; //¼ìË÷Ç° 5 ¸ö¼Ç¼ÐÐ //»»¾ä»°Ëµ£¬LIMIT n µÈ¼ÛÓÚ LIMIT 0,n¡£
 
 ºÍ´ó¼ÒÒ»ÆðѧϰSQLµÄINSERT INTO\UPDATE\DELETE²Ù×÷Óï¾ä£º
1.INSERT INTO
INSERT INTO ±íÃû VALUES (Öµ1, Öµ2,....) ½«Öµ1£¬Öµ2£¬ ²åÈë' ±íÃû' ÖеÄÒ»ÐÐÖµ INSERT INTO ±íÃû (ÁÐ1, ÁÐ2,...) VALUES (Öµ1, Öµ2,....) Ö¸¶¨ÁвåÈëÊý¾Ý
2.UPDATE
UPDATE ±íÃû SET ÁÐÃû = 'Öµ2' WHERE ÁÐÃû = 'Öµ1' ÔÚ±íÖн«Ô­ÁÐֵΪֵ1µÄ£¬ÉèÖÃΪֵ2
2.DELETE
DELETE from ±íÃû WHERE ÁÐÃû = 'Öµ1' ɾ³ýÁÐÃûֵΪֵ1µÄÐÐ DELETE from ±íÃû WHERE ÁÐÃû = 'Öµ1' DELETE * from ±íÃû DELETE from ±íÃû ɾ³ý±íÃûËùÓеÄÐÐ


Ïà¹ØÎĵµ£º

SQL ServerÖÐ charÓëvarchar  

¹Ì¶¨³¤¶È(char)Óë¿É±ä³¤¶È(varchar)×Ö·ûÊý¾ÝÀàÐÍ
char[(n)]
³¤¶ÈΪn¸ö×ֽڵĹ̶¨³¤¶ÈÇÒ·ÇUnicodeµÄ×Ö·ûÊý¾Ý¡£n±ØÐëÊÇÒ»¸ö½éÓÚ1ºÍ8,000Ö®¼äµÄÊýÖµ¡£´æ´¢´óСΪn¸ö×Ö½Ú¡£charÔÚSQL-92ÖеÄͬÒå´ÊΪcharacter¡£
varchar[(n)]
³¤¶ÈΪn¸ö×ֽڵĿɱ䳤¶ÈÇÒ·ÇUnicodeµÄ×Ö·ûÊý¾Ý¡£n±ØÐëÊÇÒ»¸ö½éÓÚ1ºÍ8,000Ö®¼äµÄÊýÖµ¡£´æ´¢´óСΪ ......

sql serverÈÕÆÚʱ¼äº¯Êý

Sql ServerÖеÄÈÕÆÚÓëʱ¼äº¯Êý
1.  µ±Ç°ÏµÍ³ÈÕÆÚ¡¢Ê±¼ä
    select getdate() 
2. dateadd  ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ
   ÀýÈ磺ÏòÈÕÆÚ¼ÓÉÏ2Ìì
   select dateadd(day,2,'2004-10-15')  --·µ»Ø£º2004-10-17 00:00:00.000 ......

SqlÔÚMysqlµÄÖ´ÐÐ

     ×òÌì½âÎöÁËdblp.xml£¬´æÈëÊý¾Ý¿â£¬Éú³ÉÁËÈô¸ÉÕÅÁÙʱ±í¡£½ñÌìÉÏÎ磬¶ÔÕâЩÁÙʱ±í½øÐд¦Àí£¬È»ºó´æÈëʵÑéÉè¼ÆµÄ±íÖС£Êý¾Ý¿âµÄÊý¾ÝÁ¿±È½Ï´ó£¬50¶àM£¬80¶àÍòÌõ¼Ç¼¡£Òò¶øÖ´ÐÐsqlʱ£¬¾ÍÓöµ½Á˺ܶàÎÊÌâ¡£
1¡¢È¥³ýÖظ´tuple
     ԭʼdblp.xmlÖУ¬Í¬Ò»ÂÛÎĵĴæÔÚ¼¸¸öÍêÈ«ÏàͬµÄ&l ......

SQL CLR ¼¯³É

Ò»¡¢ÅäÖà SQL Server£¬Ê¹Ö®ÔÊÐí CLR ¼¯³É:
¡¡¡¡1.µ¥»÷“¿ªÊ¼”°´Å¥£¬ÒÀ´ÎÖ¸Ïò“ËùÓгÌÐò”¡¢Microsoft SQL Server 2005 ºÍ“ÅäÖù¤¾ß”£¬È»ºóµ¥»÷“ÍâΧӦÓÃÅäÖÃÆ÷”¡£
¡¡¡¡2.ÔÚ SQL Server 2005 ÍâΧӦÓÃÅäÖÃÆ÷¹¤¾ßÖУ¬µ¥»÷“¹¦ÄܵÄÍâΧӦÓÃÅäÖÃÆ÷”¡£
¡¡¡¡3.Ñ¡ÔñÄ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ