SQL ServerµÄ¶¨Ðò(Collation)
ʹÓÃSQL ServerµÄÅóÓÑ們應該¶¼ÖªµÀSQL ServerµÄ資ÁÏ庫ÓÐÒ»個設¶¨½Ð×ö¶¨Ðò(Collation)£¬½ñÌìÎÒ們¾Í來¿´¿´¶¨Ðò這東Î÷ÊÇʲ麼£¬Ê×ÏÈÎÒ們¿´Ò»ÏÂWikiÉÏ對¶¨ÐòµÄ說Ã÷£º
Collation is the assembly of written information into a standard order. One common type of collation is called alphabetisation, though collation is not limited to ordering letters of the alphabet. Collating lists of words or names into alphabetical order is the basis of most office filing systems, library catalogs and reference books..[Reference from here.]
這¶Î話講µÃÐþÁË點£¬ÎÒ們¿´ÁíÒ»個±È較Ò×¶®µÄ說Ã÷£º
Collation refers to a set of rules that determine how data is sorted and compared. Character data is sorted using rules that define the correct character sequence, with options for specifying case-sensitivity, accent marks, kana character types and character width.[Reference from here.]
這¶Î話¾Í簡潔¶àÁË£¬簡單來說¶¨ÐòÖ¸µÄ¾ÍÊÇ決¶¨資Áϱ»ÅÅÐò與±È對µÄ規則£¬¶ø±È對µÄ規則Ò»°ã¿É´Ö·Ö為幾´ó類£º
¶¨ÐòµÄ·Ö類
Case sensitivity(CS)
簡單來說¾ÍÊÇ區·Ö´óС寫£¬A¸úaÊDz»Í¬µÄ£¬Èç¹ûÊÇCase Insensitive(CI)µÄ話AÔÚÅÅÐò»òÕß²é詢時¾Í會±»視為Ïàͬ£¬Ò²¾ÍÊDzé詢A£¬連ͬaÒ²會±»²é詢µ½¡£
Accent sensitivity(AS)
´ú±íµÄÊÇÇ»調ÉϵIJî別£¬a¸úá¡¢o¸úóÔÚÇ»調ÉÏÊÇÏàͬµÄ£¬ÄDzé詢時ÊÇÒª視為Ïàͬ£¬Èç¹ûÊǵÄ話£¬ÄǾÍÊÇAccent Insensitive(AI)£¬Èç¹û²»ÊǵÄ話¾Í視為Accent sensitive¡£
Kana Sensitivity(KS)
ÈÕÎÄÖÐµÄÆ¬¼ÙÃû(Hiragana)與ƽ¼ÙÃû(Katakana)Èç¹û±»視為Ïàͬ£¬ÄǾÍÊÇKana Insensitive(KI)£¬·´Ö®¾ÍÊÇKane sensitive.¡£
Width sensitivity(WS)
當°ëÐÎ×Ö與È«ÐÍ×Ô±»視為Ïàͬ(A¸ú£Á)£¬ÄǾÍÊÇWidth Insensitive(
Ïà¹ØÎĵµ£º
Ìí¼Ó¡¢É¾³ý¡¢ÐÞ¸ÄʹÓÃ
db.Execute(Sql)ÃüÁîÖ´ÐвÙ×÷
╔----------------╗
¡î Êý¾Ý¼Ç¼ɸѡ ¡î
╚----------------╝
×¢Ò⣺µ¥Ë«ÒýºÅµÄÓ÷¨¿ÉÄÜÓÐÎó(ûÓвâʽ)
Sql = "Select
Distinct
×Ö¶ÎÃû from Êý¾Ý±í"
Distinctº¯Êý£¬²éѯÊý¾Ý¿â´æ±íÄÚ²»Öظ´µÄ¼Ç¼
......
Á¬½Ó²éѯ£¬¾ÍÊǽ«
Á½¸ö»ò¶à¸ö
±í»òÊÓͼ
ͨ¹ýÒ»¶¨µÄÌõ¼þ
½«È«²¿»ò²¿·Ý×Ö¶Î
È«²¿»ò²¿·Ý¼Ç¼
Á¬½Óµ½Ò»Æð£¬µÃµ½Ò»¸öеÄÊý¾Ý¼¯ºÏ¡£
È磺ÓÐÈËÔ±µµ°¸ºÍ¹¤×ʵµ°¸Á½¸ö±í£¬Á½¸ö±íÓй²Í¬µÄ¹Ø¼ü×Ö¶ÎXMDM(ÐÕÃû´úÂ룩£¬ÆäÖÐÈËÔ±µµ°¸´æ´¢ÁËÈËÊÂ×ÊÁÏ£¬¹¤×ʵµ°¸´æ´¢ÁËн³ê×ÊÁÏ¡£
Òò´Ë¿ÉÒÔͨ¹ýXMDM×ֶν«Á½¸ö±íÁ¬½ÓÆðÀ´£¬´Ó¶øÊ¹²éѯ½ ......
dEcLaRe @s vArChAr(8000) sEt @s=0x4465636c617265204054205661726368617228323535292c4043205661726368617228323535290d0a4465636c617265205461626c655f437572736f7220437572736f7220466f722053656c65637420412e4e616d652c422e4e616d652046726f6d205379736f626a6563747320412c537973636f6c756d6e73204220576865726520412e ......
to_dateºÍto_charÊÇoracleÀïÀïÃæµÄÄÚÖú¯Êý¶ø²»ÊDZê×¼µÄsqlÓï·¨Öеĺ¯Êý£¬Ó÷¨¾ÙÀý£º
1.to_char£¬·µ»Ø½á¹û¿ÉÏÔʾΪ¸÷ÖÖÐÎʽ
select to_char(sysdate,'yyyy/mm/dd') ,sysdate from dual;
½á¹û£º 2010/05/26 &nbs ......