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

×ܽáSQLite²»Ö§³ÖµÄSQLÓï·¨ÓÐÄÄЩ


1 TOP
ÕâÊÇÒ»¸ö´ó¼Ò¾­³£Îʵ½µÄÎÊÌ⣬ÀýÈçÔÚSQLSERVERÖпÉÒÔʹÓÃÈçÏÂÓï¾äÀ´È¡µÃ¼Ç¼¼¯ÖеÄÇ°Ê®Ìõ¼Ç¼£º
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
 
µ«ÊÇÕâÌõSQLÓï¾äÔÚSQLiteÖÐÊÇÎÞ·¨Ö´Ðеģ¬Ó¦¸Ã¸ÄΪ£º
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
 
ÆäÖÐlimit 0,10±íʾ´ÓµÚ0Ìõ¼Ç¼¿ªÊ¼£¬ÍùºóÒ»¹²¶ÁÈ¡10Ìõ
 
2 ´´½¨ÊÓͼ£¨Create View£©
SQLiteÔÚ´´½¨¶à±íÊÓͼµÄʱºòÓÐÒ»¸öBUG£¬ÎÊÌâÈçÏ£º
CREATE VIEW watch_single AS SELECT DISTINCT watch_item.[watchid],watch_item.[itemid] from watch_item;
 
ÉÏÃæÕâÌõSQLÓï¾äÖ´Ðкó»áÏÔʾ³É¹¦£¬µ«ÊÇʵ¼ÊÉϳýÁË
SELECT COUNT(*) from [watch_single ] WHERE watch_ single.watchid = 1;
ÄÜÖ´ÐÐÖ®ÍâÊÇÎÞ·¨Ö´ÐÐÆäËûÈκÎÓï¾äµÄ¡£ÆäÔ­ÒòÔÚÓÚ½¨Á¢ÊÓͼµÄʱºòÖ¸¶¨ÁË×Ö¶ÎËùÔڵıíÃû£¬¶øSQLite²¢²»ÄÜÕýÈ·µØʶ±ðËü¡£ËùÒÔÉÏÃæµÄ´´½¨Óï¾äÒª¸ÄΪ£º
CREATE VIEW watch_single AS SELECT DISTINCT [watchid],[itemid] from watch_item;
 
µ«ÊÇËæÖ®¶øÀ´µÄÎÊÌâÊÇÈç¹ûÊǶà±íµÄÊÓͼ£¬ÇÒ±í¼äÓÐÖØÃû×ֶεÄʱºò¸ÃÔõô°ì£¿
 
3 COUNT£¨DISTINCT column£©
SQLiteÔÚÖ´ÐÐÈçÏÂÓï¾äµÄʱºò»á±¨´í£º
SELECT COUNT(DISTINCT watchid) from [watch_item] WHERE watch_item.watchid = 1;
ÆäÔ­ÒòÊÇSQLiteµÄËùÓÐÄÚÖú¯Êý¶¼²»Ö§³ÖDISTINCTÏÞ¶¨£¬ËùÒÔÈç¹ûҪͳ¼Æ²»Öظ´µÄ¼Ç¼ÊýµÄʱºò»á³öÏÖһЩÂé·³¡£±È½Ï¿ÉÐеÄ×ö·¨ÊÇÏȽ¨Á¢Ò»¸ö²»Öظ´µÄ¼Ç¼±íµÄÊÓͼ£¬È»ºóÔÙ¶Ô¸ÃÊÓͼ½øÐмÆÊý¡£
 
4 ÍâÁ¬½Ó
ËäÈ»SQLite¹Ù·½ÒѾ­Éù³ÆLEFT OUTER JOIN ÒѾ­ÊµÏÖ£¬µ«»¹Ã»ÓÐ RIGHT OUTER JOIN ºÍ FULL OUTER JOIN¡£µ«ÊÇʵ¼Ê²âÊÔ±íÃ÷Ëƺõ²¢²»Äܹ»Õý³£µÄ¹¤×÷¡£ÒÔÏÂÈýÌõÓï¾äÔÚÖ´ÐеÄʱºò¾ù»á±¨´í£º
SELECT tags.[tagid] from [tags],[tag_rss] WHERE tags.[tagid] = tag_rss.[tagid](*);
 
SELECT tags.[tagid] from [tags],[tag_rss] WHERE LEFT OUTER JOIN tag_rss.[tagid] = tags.[tagid];
 
SELECT tags.[tagid] from [tags],[tag_rss] WHERE LEFT JOIN tag_rss.[tagid] = tags.[tagid];
 
´ËÍâ¾­¹ý²âÊÔÓÃ+ºÅ´úÌæ*ºÅÒ²ÊDz»¿ÉÐеġ£
ÊÕ¼¯SQLiteÓëSql ServerµÄÓï·¨²îÒì
1.·µ»Ø×îºó²åÈëµÄ±êʶֵ
·µ»Ø×îºó²åÈëµÄ±êʶֵsql serverÓÃ@@IDENTITY
sqliteÓñêÁ¿º¯ÊýLAST_INSERT_ROWID()
·µ»Øͨ¹ýµ±Ç°µÄ SQLConnection ²åÈëµ½Êý¾Ý¿âµÄ×îºóÒ»ÐеÄÐбêʶ·û£¨É


Ïà¹ØÎĵµ£º

PL/SQL ¿ØÖƽṹ

ÔÚPL/SQLÖÐÒýÈëÁË¿ØÖƽṹ£¬°üÀ¨Ñ¡Ôñ½á¹¹£¬Ñ­»·½á¹¹ºÍÌøת½á¹¹
Ò» Ñ¡Ôñ½á¹¹
1,IF Óï¾ä
 
    ÔÚPL/SQLÖУ¬Ñ¡Ôñ½á¹¹¿ÉÒÔͨ¹ýifÓï¾äÀ´ÊµÏÖ£¬Ò²¿ÉÒÔͨ¹ýCaseÓï¾ä£¨oracle9iÖУ©
    ÀûÓÃifÓï¾äʵÏÖÑ¡Ôñ¿ØÖƵÄÓ﷨Ϊ£º
     if condition1 then statements1 ......

dz̸SQL½Ì³ÌÖ®Group byºÍHaving

ÔÚ½éÉÜGROUP BY ºÍ HAVING ×Ó¾äÇ°£¬ÎÒÃDZØÐèÏȽ²½²sqlÓïÑÔÖÐÒ»ÖÖÌØÊâµÄº¯Êý£º¾ÛºÏº¯Êý£¬ÀýÈçSUM, COUNT, MAX, AVGµÈ¡£ÕâЩº¯ÊýºÍÆäËüº¯ÊýµÄ¸ù±¾Çø±ð¾ÍÊÇËüÃÇÒ»°ã×÷ÓÃÔÚ¶àÌõ¼Ç¼ÉÏ¡£
      SELECT SUM(population) from bbc
¡¡¡¡ÕâÀïµÄSUM×÷ÓÃÔÚËùÓзµ»Ø¼Ç¼µÄpopulation×Ö¶ÎÉÏ£¬½á¹û¾ÍÊǸòéÑ ......

SQL Ëæ»ú³éÑùµÄ×ܽá

¶ÔÓÚSQL Ëæ»ú³éÑùÎÒÃdz£Ïëµ½µÄ¾ÍÊÇnewid()£¬µ«Èç¹û¶ÔÓÚÒ»¸öÔÚ°ÙÍò¡¢Ç§ÍòÉõÖÁ¸ü´óº£Á¿Êý¾Ý±íÖгéÑùµÄ»°£¬¼òµ¥µÄnewid()£¬ÆäÐÔÄÜ£¬Ð§ÂʾͲ»ÊǺÜÀíÏëÁË¡£ËùÒÔÔÚÕâÀïÓбØÒªÌÖÂÛһϣ¬ÔñÓŶøÓá£
 
long_goodsÊÇÒ»¸ö°ÙÍòÊý¾ÝµÄ±í£¬Ctrl+LÖ´ÐÐÒÔÏÂÓï¾ä:
 
--id_indexÊÇÎÒΪÖ÷¼ü¼ÓµÄÒ»¸ö·Ç¾Û½¹Ë÷Òý
SELECT top 1&nb ......

ʹÓÃT SQL»ñÈ¡µ½SQLServer IpºÍ¶Ë¿ÚºÅ

ÔÚƽʱµÄ¹¤×÷¹ý³ÌÖУ¬×÷ΪDBA½ÇÉ«¹ÜÀíÊý¾Ý¿â£¬Í·ÄÔÖеÄÓ¡ÏóÍùÍùÊÇÊý¾Ý¿âʵÀýÃû³Æ£¬¶ø²»»áÈ¥¹ØÐÄServerµÄIP£¬¶ø×÷ΪDeveloperµÄ½ÇÉ«£¬ËûÃÇÍùÍùÏëÖªµÀÖªµÀServer IpºÍ¶Ë¿ÚºÅ¡£ËùÒÔ£¬DBA»á¾­³£±»Îʼ°µ½£ºXXXʵÀýµÄIPºÍ¶Ë¿ÚºÅÊÇʲô£¿
Õâ¸öÎÊÌ⣬µ±È»ÎÒÃÇ¿ÉÒÔLoginµ½OS²é¿´IP¡¢Ê¹ÓÃÅäÖƹÜÀí¹¤¾ß»ñÈ¡µ½¶Ë¿ÚºÅ¡£µ«ÊÇ£¬Õâ¸ö·½·¨·Ç ......

sql server2000´æ´¢¹ý³Ì·þÎñÆ÷

´æ´¢¹ý³Ì
ÔÚ´óÐÍÊý¾Ý¿âϵͳÖУ¬Ëæ׏¦ÄܵIJ»¶ÏÍêÉÆ£¬ÏµÍ³Ò²±äµÃÔ½À´Ô½¸´ÔÓ£¬´óÁ¿µÄʱ¼ä½«»áºÄ·ÑÔÚSQL´úÂëºÍÓ¦ÓóÌÐò´úÂëÉÏ£¬¿öÇÒÔںܶàÇé¿öÏ£¬Ðí¶à´úÂë±»Öظ´Ê¹Óöà´Î£¬Ã¿´Î¶¼ÊäÈëÏàͬµÄ´úÂë¼È·±ËöÓֻήµÍϵͳÔËÐÐЧÂÊ¡£Òò´Ë£¬SQL ServerÌṩÁËÒ»ÖÖ·½·¨£¬Ëü¿ÉÒÔ½«Ò»Ð©¹Ì¶¨µÄ²Ù×÷¼¯ÖÐÆðÀ´ÓÉSQL ServerÊý¾Ý¿â·þÎñÆ÷À´Íê³É£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ