¼¸Ìõ³£¼ûµÄÊý¾Ý¿â·ÖÒ³ SQL Óï¾ä
ÎÒÃÇÔÚ±àдMISϵͳºÍWebÓ¦ÓóÌÐòµÈϵͳʱ£¬¶¼Éæ¼°µ½ÓëÊý¾Ý¿âµÄ½»»¥£¬Èç¹ûÊý¾Ý¿âÖÐÊý¾ÝÁ¿ºÜ´óµÄ»°£¬Ò»´Î¼ìË÷ËùÓеļǼ£¬»áÕ¼ÓÃϵͳºÜ´óµÄ×ÊÔ´£¬Òò´ËÎÒÃdz£³£²ÉÓã¬ÐèÒª¶àÉÙÊý¾Ý¾ÍÖ»´ÓÊý¾Ý¿âÖÐÈ¡¶àÉÙÌõ¼Ç¼£¬¼´²ÉÓ÷ÖÒ³Óï¾ä¡£¸ù¾Ý×Ô¼ºÊ¹ÓùýµÄÄÚÈÝ£¬°Ñ³£¼ûÊý¾Ý¿âSQL Server,OracleºÍMySQLµÄ·ÖÒ³Óï¾ä£¬´ÓÊý¾Ý¿â±íÖеĵÚMÌõÊý¾Ý¿ªÊ¼È¡NÌõ¼Ç¼µÄÓï¾ä×ܽáÈçÏ£º
¡¡¡¡SQL Server
¡¡¡¡´ÓÊý¾Ý¿â±íÖеĵÚMÌõ¼Ç¼¿ªÊ¼È¡NÌõ¼Ç¼£¬ÀûÓÃTop¹Ø¼ü×Ö£º×¢ÒâÈç¹ûSelectÓï¾äÖмÈÓÐtop£¬ÓÖÓÐorder by£¬ÔòÊÇ´ÓÅÅÐòºÃµÄ½á¹û¼¯ÖÐÑ¡Ôñ£º
¡¡¡¡SELECT *
¡¡¡¡from ( SELECT Top N *
¡¡¡¡from (SELECT Top (M + N - 1) * from ±íÃû³Æ Order by Ö÷¼ü desc) t1 ) t2
¡¡¡¡Order by Ö÷¼ü asc
¡¡¡¡ÀýÈç´Ó±íSys_option(Ö÷¼üΪsys_id)ÖдÓ10Ìõ¼Ç¼»¹ÊǼìË÷20Ìõ¼Ç¼£¬Óï¾äÈçÏ£º
¡¡¡¡SELECT *
¡¡¡¡from ( SELECT TOP 20 *
¡¡¡¡from (SELECT TOP 29 * from Sys_option order by sys_id desc) t1) t2
¡¡¡¡Order by sys_id asc
¡¡¡¡OralceÊý¾Ý¿â
¡¡¡¡´ÓÊý¾Ý¿â±íÖеÚMÌõ¼Ç¼¿ªÊ¼¼ìË÷NÌõ¼Ç¼
¡¡¡¡SELECT *
¡¡¡¡from (SELECT ROWNUM r,t1.* from ±íÃû³Æ t1 where rownum < M + N) t2
¡¡¡¡where t2.r >= M
¡¡¡¡ÀýÈç´Ó±íSys_option(Ö÷¼üΪsys_id)ÖдÓ10Ìõ¼Ç¼»¹ÊǼìË÷20Ìõ¼Ç¼£¬Óï¾äÈçÏ£º
¡¡¡¡SELECT *
¡¡¡¡from (SELECT ROWNUM R,t1.* from Sys_option where rownum < 30 ) t2
¡¡¡¡Where t2.R >= 10
¡¡¡¡MySQLÊý¾Ý¿â
¡¡¡¡My SQLÊý¾Ý¿â×î¼òµ¥£¬ÊÇÀûÓÃmySQLµÄLIMITº¯Êý,LIMIT [offset,] rows´ÓÊý¾Ý¿â±íÖÐMÌõ¼Ç¼¿ªÊ¼¼ìË÷NÌõ¼Ç¼µÄÓï¾äΪ£º
¡¡¡¡SELECT * from ±íÃû³Æ LIMIT M,N
¡¡¡¡ÀýÈç´Ó±íSys_option(Ö÷¼üΪsys_id)ÖдÓ10Ìõ¼Ç¼»¹ÊǼìË÷20Ìõ¼Ç¼£¬Óï¾äÈçÏ£º
¡¡¡¡select * from sys_option limit 10,20
Ïà¹ØÎĵµ£º
SQLÖظ´¼Ç¼²éѯ
1¡¢²éÕÒ±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´ÅжÏ
select * from
people
where peopleId in (select peopleId from people group by peopleId
having count
(peopleId) > 1)
2¡¢É¾³ý±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨p ......
MMC ²»ÄÜ´ò¿ªÎļþ C:\Program Files\Microsoft SQL Server\80\Tools\BINN\SQL Server Enterprise Manager.MSC¡£¿ÉÒÔÔÒòÊÇÎļþ²»´æÔÚ£¬²»ÊÇÒ»¸öMMC¿ØÖÆ̨£¬»òÕßÓúóÀ´MMC°æ±¾´´½¨£¬Ò²ÐíҲûÓзÃÎÊ´ËÎļþµÄ×㹻ȨÏÞ¡£
½â¾ö·½·¨£º
ÖØд´½¨´ËÎļþ£¬ÔËÐжԻ°¿òÖÐÊäÈë:mmc
1) ¿ØÖÆ̨-->Ìí¼Ó/ɾ³ý¹ÜÀíµ¥Ôª-->Ìí¼ ......
ÔÚSQLÖÐSelectÓï¾äµÄÖ´ÐÐ˳ÐòÈçÏ£º
(1)from×Ӿ䣬×é×°À´×Ô²»Í¬Êý¾ÝÔ´µÄÊý¾Ý
(2)WHERE×Ӿ䣬¸øÓèÖ¸¶¨Ìõ¼þ¶Ô¼Ç¼½øÐÐɸѡ
(3)GROUP BY×Ӿ䣬½«Êý¾Ý»®·ÖΪ¶à¸ö×é
(4)ʹÓþۼ¯º¯Êý½øÐмÆËã
(5)ʹÓÃHAVING×Ó¾äɸѡ·Ö×é
(6)¼ÆËãËùÓбí´ïʽ
(7)ʹÓÃORDER BY¶Ô½á¹û½øÐÐÅÅÐò ......
ÈÕÆÚ£º2003 Äê 2 Ô 19 ÈÕ
Íê³É´Ë·½·¨Ö¸ÄϺó£¬ÄúÓ¦¸ÃÄܹ»£º
ÔÚ Oracle Êý¾Ý¿âÖд´½¨ VARRAY
ʹÓà oracle.sql.ARRAY Àà
´Ó Java ·ÃÎÊ VARRAY
¼ò½é
±¾ÎĵµÑÝʾÈçºÎ´Ó PL/SQL º¯Êý·µ»ØÊý×é²¢´Ó java Ó¦ÓóÌÐò·ÃÎÊËü¡£Êý×éÊÇÒ»×éÓÐÐòµÄÊý¾ÝÔªËØ¡£ VARRAY ÊÇ´óС¿É±äµÄÊý×é¡£Ëü¾ßÓÐÊý¾ÝÔªËصÄÅÅÁм¯£¬²¢ÇÒËùÓÐÔªËØÊôÓÚ ......
SQL ÊÇÒ»ÃÅ ANSI µÄ±ê×¼¼ÆËã»úÓïÑÔ£¬ÓÃÀ´·ÃÎʺͲÙ×÷Êý¾Ý¿âϵͳ¡£SQL Óï¾äÓÃÓÚÈ¡»ØºÍ¸üÐÂÊý¾Ý¿âÖеÄÊý¾Ý¡£SQL ¿ÉÓëÊý¾Ý¿â³ÌÐòÐͬ¹¤×÷£¬±ÈÈç MS Access¡¢DB2¡¢Informix¡¢MS SQL Server¡¢Oracle¡¢Sybase ÒÔ¼°ÆäËûÊý¾Ý¿âϵͳ¡£
²»ÐÒµØÊÇ£¬´æÔÚןܶ಻ͬ°æ±¾µÄ SQL ÓïÑÔ£¬µ«ÊÇΪÁËÓë ANSI ±ê×¼Ïà¼æÈÝ£¬ËüÃDZØÐëÒÔÏàËÆµÄ ......