oracle distinctÓ÷¨
distinctÕâ¸ö¹Ø¼ü×ÖÀ´¹ýÂ˵ô¶àÓàµÄÖظ´¼Ç¼ֻ±£ÁôÒ»Ìõ£¬µ«ÍùÍùÖ»Óà ËüÀ´·µ»Ø²»Öظ´¼Ç¼µÄÌõÊý£¬¶ø²»ÊÇÓÃËüÀ´·µ»Ø²»ÖؼǼµÄËùÓÐÖµ¡£ÆäÔÒòÊÇdistinctÖ»ÓÐÓöþÖØÑ»·²éѯÀ´½â¾ö£¬¶øÕâÑù¶ÔÓÚÒ»¸öÊý¾ÝÁ¿·Ç³£´óµÄÕ¾À´Ëµ£¬ÎÞÒÉÊÇ»áÖ±½ÓÓ°Ï쵽ЧÂʵġ£
ÏÂÃæÏÈÀ´¿´¿´Àý×Ó£º
table±í
×Ö¶Î1 ×Ö¶Î2
id name
1 a
2 b
3 c
4 c
5 b
¿â½á¹¹´ó¸ÅÕâÑù£¬ÕâÖ»ÊÇÒ»¸ö¼òµ¥µÄÀý×Ó£¬Êµ¼ÊÇé¿ö»á¸´Ôӵöࡣ
±ÈÈçÎÒÏëÓÃÒ»ÌõÓï¾ä²éѯµÃµ½name²»Öظ´µÄËùÓÐÊý¾Ý£¬ÄǾͱØÐëʹÓÃdistinctÈ¥µô¶àÓàµÄÖظ´¼Ç¼¡£
select distinct name from table
µÃµ½µÄ½á¹ûÊÇ:
----------
name
a
b
c
ºÃÏñ´ïµ½Ð§¹ûÁË£¬¿ÉÊÇ£¬ÎÒÏëÒªµÃµ½µÄÊÇidÖµÄØ£¿¸ÄһϲéѯÓï¾ä°É:
select distinct name, id from table
½á¹û»áÊÇ:
----------
id name
1 a
2 b
3 c
4 c
5 b
distinctÔõôûÆð×÷Óã¿×÷ÓÃÊÇÆðÁ˵ģ¬²»¹ýËûͬʱ×÷ÓÃÁËÁ½¸ö×ֶΣ¬Ò²¾ÍÊDZØÐëµÃidÓëname¶¼ÏàͬµÄ²Å»á±»Åųý¡£¡£¡£¡£¡£¡£¡£
ÎÒÃÇÔٸĸIJéѯÓï¾ä:
select id, distinct name from table
ºÜÒź¶£¬³ýÁË´íÎóÐÅÏ¢ÄãʲôҲµÃ²»µ½£¬distinct±ØÐë·ÅÔÚ¿ªÍ·¡£Äѵ½²»ÄÜ°Ñdistinct·Åµ½whereÌõ¼þÀÄÜ£¬ÕÕÑù±¨´í¡£
------------------------------------------------------------------------------------------------------------
ÏÂÃæ·½·¨¿ÉÐÐ:
select *, count(distinct name) from table group by name
½á¹û:
id name count(distinct name)
1 a 1
2 b 1
3 c 1
×îºóÒ»ÏîÊǶàÓàµÄ£¬²»ÓùܾÍÐÐÁË£¬Ä¿µÄ´ïµ½¡£¡£¡£¡£¡£
group by ±ØÐë·ÅÔÚ order by ºÍ limit֮ǰ£¬²»È»»á±¨´í
Ïà¹ØÎĵµ£º
¸½:Oracle SQL Developer — À©Õ¹½»Á÷ÖÐÐÄ
http://www.oracle.com/technology/global/cn/products/database/sql_developer/files/extensions.htm
֮ǰ×÷Ϊһ¸öOracle Employee£¬È´×ÜÊÇÔÚʹÓÃPL/SQL Developer£¨¶øÇÒÊÇÆƽâ°æ£©£¬ÕâʵÔÚÓÐЩ˵²»¹ýÈ¥£¬µ«ÊÇÈçºÎÕÒµ½Ò»¸öºÏÐijÃÊÖµÄÄܹ»Ô ......
ÍüÁËOracleµÄsysÓû§ºÍMySQLµÄrootÓû§ÃÜÂ룬½â¾ö·½·¨
2007Äê03ÔÂ16ÈÕ ÐÇÆÚÎå 09:44
×÷Õߣºhexiong¡¡
°æȨÉùÃ÷£º¿ÉÒÔÈÎÒâתÔØ£¬×ªÔØʱÇëÎñ±ØÒÔ³¬Á´½ÓÐÎʽ±êÃ÷ÎÄÕÂÔʼ³ö´¦ºÍ×÷ÕßÐÅÏ¢¼°±¾ÉùÃ÷¡£
http://hi.baidu.com/hexiong/blog/item/b4acd72a85272d2cd42af1b1.html
¾³£Åöµ½ÓÐÈËÔÚÂÛ̳ÉÏÎÊÕâ¸öÎÊÌ⣬¸É´àÔÚÕâÀï×ܽáÒ ......
½ñÌì×öÏîÄ¿µÄʱºò£¬½«null´«ÈëOracleµÄ±íÖУ¬¾ÍÊDz»³É¹¦
¾¹ý³¢ÊԵóöÁËÁ½¸ö½â¾ö·½°¸£º
1.´«ÈëOracleDateTime.NULL
2.Nullable<DateTime> optime = DBNull.Value; ´«Èëoptime(¿ªÊ¼ÍøÉÏÕҵĴð°¸ÊÇNullable<DateTime> optime = null·¢ÏÖ»¹Êǻᱨ´í) ......
Ò»¡¢¼àÌýÆ÷(LISTENER)
¡¡¡¡¼àÌýÆ÷ÊÇOracle»ùÓÚ·þÎñÆ÷¶ËµÄÒ»ÖÖÍøÂç·þÎñ£¬Ö÷ÒªÓÃÓÚ¼àÌý¿Í»§¶ËÏòÊý¾Ý¿â·þÎñÆ÷¶ËÌá³öµÄÁ¬½ÓÇëÇó¡£¼ÈÈ»ÊÇ»ùÓÚ·þÎñÆ÷¶ËµÄ·þÎñ£¬ÄÇôËüÒ²Ö»´æÔÚÓÚÊý¾Ý¿â·þÎñÆ÷¶Ë£¬½øÐмàÌýÆ÷µÄÉèÖÃÒ²ÊÇÔÚÊý¾Ý¿â·þÎñÆ÷¶ËÍê³ÉµÄ¡£
¶þ¡¢±¾µØ·þÎñÃû(Tnsname)
¡¡¡¡Oracle¿Í»§¶ËÓë·þÎñÆ÷¶ËµÄÁ¬½ÓÊÇͨ¹ý¿Í»§¶Ë· ......