SQL·ÖÒ³²éѯ
thunder:
1.MYSQLʵÏÖ
mysql> select * from user;
+----+----------+----------+-----------------+
| ID | username | password | email |
+----+----------+----------+-----------------+
| 1 | admin | admin | abc@yahoo.cn |
| 2 | thomas | 159753 | thomas@yahoo.cn |
| 3 | thomas1 | 159753 | thomas@yahoo.cn |
| 4 | huhu | 159753 | hu@yahoo.cn |
| 5 | fdg | dfg | fdg |
| 6 | sdf | sd | sdf@yahoo.cn |
| 7 | d | d | d@d.cn |
+----+----------+----------+-----------------+
7 rows in set (0.00 sec)
mysql> select * from user limit 3,2;
+----+----------+----------+-------------+
| ID | username | password | email |
+----+----------+----------+-------------+
| 4 | huhu | 159753 | hu@yahoo.cn |
| 5 | fdg | dfg | fdg |
+----+----------+----------+-------------+
2 rows in set (0.00 sec)
mysql>
===================================================
2.MSSQLServerʵÏÖ
select top 5 function_id,function_name from d_function
where function_id not in (select top 5 function_id from d_function)
6 ÔÂͳ¼Æ
7 ²¿ÃŲéѯ
8 ¹«Ë¾²éѯ
9 ¹¤³ÌÕбê
10 ¹¤³Ì×ܽá
Ïà¹ØÎĵµ£º
·½·¨Ò»¡¢¾¡Á¿Ê¹Óø´ÔÓµÄSQLÀ´´úÌæ¼òµ¥µÄÒ»¶Ñ SQL.
ͬÑùµÄÊÂÎñ£¬Ò»¸ö¸´ÔÓµÄSQLÍê³ÉµÄЧÂʸßÓÚÒ»¶Ñ¼òµ¥SQLÍê³ÉµÄЧÂÊ¡£Óжà¸ö²éѯʱ£¬ÒªÉÆÓÚʹÓÃJOIN¡£
oRs=oConn.Execute("SELECT * from Books")
while not oRs.Eof
strSQL = "SELECT * from Authors WHERE AuthorID="&oRs("AuthorID") oRs2=oConn.Execute(strSQ ......
--MyDBΪÐÞ¸´µÄÊý¾ÝÃû
USE MASTER
GO
SP_CONFIGURE 'ALLOW UPDATES',1 RECONFIGURE WITH OVERRIDE
GO
ALTER DATABASE MyDB SET EMERGENCY
GO
sp_dboption 'MyDB', 'single user', 'true'
GO
DBCC CHECKDB('MyDB','REPAIR_ALLOW_DATA_LOSS')
GO
ALTER DATABASE MyDB SET ONLINE
GO
sp_configure 'allow updates ......
ÔÚÊý¾Ý¿âÓ¦ÓõÄÉè¼ÆÖУ¬ÎÒÃÇÍùÍù»áÐèÒª»ñȡijЩ±íµÄ¼Ç¼×ÜÊý£¬ÓÃÓÚÅжϱíµÄ¼Ç¼×ÜÊýÊÇ·ñ¹ý´ó£¬ÊÇ·ñÐèÒª±¸·ÝÊý¾ÝµÈ¡£ÎÒÃÇͨ³£µÄ×ö·¨ÊÇ£ºselect count(*) as c from tableA ¡£È»¶ø¶ÔÓڼǼÊý¾Þ´óµÄ±í£¬ÉÏÊö×ö·¨½«»á·Ç³£ºÄʱ¡£ÔÚDELL 4400 ·þÎñÆ÷ÉÏ×öÊÔÑ飬MS Sqlserver 2000 Êý¾Ý¿â¶ÔÓÚ100Íò¼Ç¼µÄ¼òµ¥Êý¾Ý±íÖ´ÐÐÉÏÊöÓï¾ä£¬Ê± ......
CHECK Ô¼Êø(CHECK Ô¼Êø:¶¨ÒåÁÐÖпɽÓÊܵÄÊý¾ÝÖµ¡£¿ÉÒÔ½« CHECK Ô¼ÊøÓ¦ÓÃÓÚ¶à¸öÁУ¬Ò²¿ÉÒÔ½«¶à¸ö CHECK Ô¼ÊøÓ¦ÓÃÓÚµ¥¸öÁС£µ±³ýȥij¸ö±íʱ£¬Ò²½«³ýÈ¥ CHECK Ô¼Êø¡£)Ö¸¶¨¿ÉÓɱíÖÐÒ»Áлò¶àÁнÓÊܵÄÊý¾ÝÖµ»ò¸ñʽ¡£ÀýÈ磬¿ÉÒÔÒªÇó authors ±íµÄ zip ÁÐÖ»ÔÊÐíÊäÈëÎåλÊýµÄÊý×ÖÏî¡£
¡¡¡¡
¡¡¡¡¿ÉÒÔΪһ¸ö±í¶¨ÒåÐí¶à CHECK Ô¼Êø¡£¿ ......
ÔÚѧϰSQLʱ¿´µ½µÄһƬºÜºÃµÄÎÄÕ£¬ÌØÌù³öÀ´ºÍ´ó¼ÒÒ»Æð·ÖÏí£¡
ÎÒÃÇÒª×öµ½²»µ«»áдSQL,»¹Òª×öµ½Ð´³öÐÔÄÜÓÅÁ¼µÄSQLÓï¾ä¡£
£¨1£©Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
OracleµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦ ......