¹ØÓÚDB2 sql:0206n ´íÎó
½ñÌìÅöµ½Ò»¸ösql:0206nµÄ´íÎó£¬ÎÒʹÓÃselect * from xxx¿ÉÒԲ鿴±í½á¹¹ºÍÄÚÈÝ£¬È»¶øµ±ÎÒʹÓÃselect aaa from xxxµÄʱºòÈ´¸øÎÒ±¨´í£¬×îºóÅŲéÔÒòÊÇÎÒʹÓù¤¾ß½¨±í£¬½¨±íÓï¾äÊÇÀàËÆÕâÑùµÄ£ºcreate table("id" int,"name" varchar)£¬ºÃÁ˽á¹û¾ÍÊÇ×ֶθø¼ÓÁËÒýºÅ£¬ÔÚ²éѯµÄʱºòʹÓÃ*¿ÉÒÔ²éѯ£¬Ê¹Óõ¥¸ö×ֶβ»Äܲéѯ£¬ÎÒ¹À¼Æ¾ÍÊÇÒòΪ±íʹÓÃÁËÁбðÃû£¬µ«ÊǾßÌåÁбðÃû×öÁËʲôԼÊø²»Äܵ¥¸ö²é»òÕß²åÈëºÍ¸üУ¬ÎÒ¸öÈ˾õµÃÕâÖÖ±ðÃûÀàËÆÓÚÊÓͼ£¬Äܹ»²éѯµ«ÊÇûÓÐÆäËûȨÏÞ£¬ÆÁ±ÎÁËÄã¶Ô±íÔ×ֶεIJ鿴ȨÏÞ£¬ÕâÑù¾Í¿ÉÒÔ±£Ö¤ÆäËûÈËÖ»Äܲ鿴£¬¶øûÓÐȨÏÞÈ¥¸ü¸Ä£¬Èç¹ûÓв»Í¬Òâ¼û£¬Çë¶àÖ¸½Ì£¡
Ïà¹ØÎĵµ£º
--SQL Server£º
Select TOP N * from TABLE Order By NewID()
--Access£º
Select TOP N * from TABLE Order By Rnd(ID)
Rnd(ID) ÆäÖеÄIDÊÇ×Ô¶¯±àºÅ×ֶΣ¬¿ÉÒÔÀûÓÃÆäËûÈκÎÊýÖµÀ´Íê³É£¬±ÈÈçÓÃÐÕÃû×Ö¶Î(U ......
ʹÓÃLINQ to SQL½¨Ä£NorthwindÊý¾Ý¿â
ÔÚÕâ֮ǰһÆðѧ¹ýLINQ to SQLÉè¼ÆÆ÷µÄʹÓã¬ÏÂÃæ¾ÍʹÓÃÈçϵÄÊý¾ÝÄ£ÐÍ£º
µ±Ê¹ÓÃLINQ to
SQLÉè¼ÆÆ÷Éè¼ÆÒÔÉ϶¨ÒåµÄÎå¸öÀࣨProduct£¬Category£¬Customer£¬OrderºÍOrderDetail£©µÄʱºò£¬Ã¿¸öÀàÖеÄÊôÐÔ
¶¼Ó³ÉäÁËÏàÓ¦Êý¾Ý¿âÖбíµÄÁУ¬Ã¿¸öÀàµÄʵÀýÔò´ú±íÁËÊý¾Ý¿â±íÖеÄÒ»Ìõ¼Ç¼¡£ÁíÍ⣬ ......
»ù±¾µÄSql±àдעÒâÊÂÏî
¾¡Á¿ÉÙÓÃIN²Ù×÷·û£¬»ù±¾ÉÏËùÓеÄIN²Ù×÷·û¶¼¿ÉÒÔÓÃEXISTS´úÌæ¡£
²»ÓÃNOT IN²Ù×÷·û£¬¿ÉÒÔÓÃNOT EXISTS»òÕßÍâÁ¬½Ó+Ìæ´ú¡£
OracleÔÚÖ´ÐÐIN×Ó²éѯʱ£¬Ê×ÏÈÖ´ÐÐ×Ó²éѯ£¬½«²éѯ½á¹û·ÅÈëÁÙʱ±íÔÙÖ´ÐÐÖ÷²éѯ¡£¶øEXISTÔòÊÇÊ×Ïȼì²éÖ÷²éѯ£¬È»ºóÔËÐÐ×Ó²éѯֱµ½ÕÒµ½
µÚÒ»¸öÆ¥ÅäÏî¡£NOT EXISTS±ÈNOT INЧÂÊÉ ......
Êý¾Ý¿âÖеÄËùÓÐÊý¾Ý´æ´¢ÔÚ±íÖС£Êý¾Ý±í°üÀ¨ÐкÍÁС£Áоö¶¨Á˱íÖÐÊý¾ÝµÄÀàÐÍ¡£Ðаüº¬ÁËʵ¼ÊµÄÊý¾Ý¡£
ÀýÈ磬Êý¾Ý¿âpubsÖеıíauthorsÓоŸö×ֶΡ£ÆäÖеÄÒ»¸ö×Ö¶ÎÃûΪΪau_lname£¬Õâ¸ö×ֶα»ÓÃÀ´´æ´¢×÷ÕßµÄÃû×ÖÐÅÏ¢¡£Ã¿´ÎÏòÕâ¸ö±íÖÐÌí¼ÓÐÂ×÷Õßʱ£¬×÷ÕßÃû×־ͱ»Ìí¼Óµ½Õâ¸ö×ֶΣ¬²úÉúÒ»ÌõмǼ¡£
ͨ¹ý¶¨Òå×ֶ䪎 ......
Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
4¡¢Ë ......