SQL ³£Óú¯Êý ±Ê¼Ç
Garin Zhang
SQL³£Óú¯Êý£º
1. ASCII()£º·µ»Ø×Ö·û´®×î×ó¶Ë×Ö·ûµÄASCIIÂë¡£
2. CHAR()£º½«ASCIIת»»³É×Ö·û¡£(0~255)
3. LOWER()ºÍUPPER()¡£
4. STR()£º°ÑÊýÖµÐÍÊý¾Ýת»»Îª×Ö·ûÐÍÊý¾Ý
SRT(<float_expression>[,length[,<decimal>]])
LTRIM()°Ñ×Ö·û´®Í·²¿¿Õ¸ñÈ¥µô£¬RTRIM()°Ñ×Ö·û´®Î²¿Õ¸ñÈ¥µô¡£
È¡×Ó´®º¯Êý£º
1. LEFT(<chars>, length)£º·µ»Øchar×óÆðlength¸ö×Ö·û¡£
2. RIGHT(<chars>, length)£º·µ»ØcharÓÒÆðlength¸ö×Ö·û¡£
3. SUBSTRING(<chars>, <position>, length)£º·µ»Øchars×ó±ßµÚposition¸ö×Ö·ûÆðlength¸ö×Ö·û²¿·Ö¡£
×Ö·û´®±È½Ï£º
1. QUOTENAME(<chars>[,quote_char])£º·µ»Ø±»Ìض¨×Ö·ûÀ¨ÆðÀ´µÄ×Ö·û´®¡£quote_charȱʡΪ"[]"
2. REPLICATE(<chars>, integer)£º·µ»ØÒ»¸öÖظ´integer´ÎÊýµÄchars¡£
3. REVERSE(<chars>)£º½«chars×Ö·û´®µÄ×Ö·ûÅÅÁÐ˳Ðòµßµ¹¡£
4. REPLACE(str1, str2, str3)£ºÓÃstr3Ìæ»»ÔÚstr1ÖеÄ×Ó´®str2.
5. SPACE(length)£º·µ»ØÒ»¸öÓÐÖ¸¶¨³¤¶ÈµÄ¿Õ°××Ö·û´®¡£
6. STUFF(str1, start, length, str2)£ºÓÃstr2Ìæ»»str1ÖдÓstart¿ªÊ¼µÄlength³¤¶ÈµÄ×Ö·û´®¡£
Êý¾ÝÀàÐÍת»»º¯Êý£º
1. CAST(str1 AS <data_type>[length])£º½«str1ÏÔʾµÄת»»ÎªÁíÒ»Êý¾ÝÀàÐÍ¡£
2. CONVERT(<data_type>[length], <expression>[, style])¡£
ÔÚ±ê×¼SQLÖÐÓÃÓÚת»¯encoding£ºCONVERT('abc' USING utf8); // MySQL
CONVERT('abc', 'UTF8', 'LATIN'); // postgres
ÔÚSQL ServerÖУºÓëCASTÀàËÆ
ÈÕÆÚº¯Êý£º
1. day(str), ·µ»ØstrÖеÄÈÕÆÚÖµ
2. month(str), year(str)
3. DATEADD(<datepart>, <number>, <data>) // data¼ÓÉÏdatepartµÄaddÖ®ºóµÄÐÂÈÕÆÚ
4. DATEDIFF(<datepart>, <date1>, <date2>)
5. DATENAME(<datepart>, <date>) // ·µ»ØdatepartÖ¸¶¨²¿·Ö
6. DATEPART(<datepart>, <date>) //·µ»ØÕûÊý£¬DAT
Ïà¹ØÎĵµ£º
½ñÌìºÜ×ÔÈ»µÄÔÚдSqlÓï¾äµÄʱºòÓÃÁËTop£¬Ò»¿ªÊ¼Ã»·¢ÏÖÎÊÌ⣬ÒòΪÎÒ´ÓÊý¾Ý¿â¶Á³öµÄÖµÕýºÃÊÇ0£¬¶øÎÒÏ°¹ß±äÁ¿¶¨ÒåµÄʱºòÒ²¶¼¸³Öµ0£¬¿ÉÊǵ½ÎÒ²»Òª0µÄʱºòÎҾͷ¢ÏÖÎÊÌâÁË¡£ºóÀ´²ÅÖªµÀ£¬¿É°®µÄСsqlite¾¹È»Óв»Ö§³ÖµÄsqlÓï·¨¡£
¡¡¡¡¿´µ½Ä³¸öÂÛ̳ÓиöÐÂÊÖÒ²·¢ÏÖÁËÕâ¸öÎÊÌâ²¢·¢ÌûÁË£¬ÏÂÃæһţÈ˵Ļظ´ÊÇ“topÊÇÄļҵĹؼü´Ê?s ......
osql ʵÓù¤¾ß
osql ʵÓù¤¾ßʹÄúµÃÒÔÊäÈë Transact-SQL Óï¾ä¡¢ÏµÍ³¹ý³ÌºÍ½Å±¾Îļþ¡£¸ÃʵÓù¤¾ßͨ¹ý ODBC Óë·þÎñÆ÷ͨѶ¡£
Óï·¨
osql
[-?] |
&nb ......
ͬ²½Ò»ÏÂÎÒbaiduµÄblog£ºhttp://hi.baidu.com/ncheng/blog/item/bc65f82a1a6a7c335343c11c.html
Sql×¢ÈëÊÇÒ»ÖÖÈëÃż«µÍÆÆ»µ¼«´óµÄ¹¥»÷·½Ê½¡£Èç¹ûsqlÊÇÓÃ×Ö·û´®Æ´½Ó³öÀ´µÄ»°£¬ÄÇô¿Ï¶¨»á±»×¢Èë¹¥»÷£¬Ç°¶Îʱ¼ä»¹´«³öÁËij¹úÍâ´óÐÍÉç½»ÍøÕ¾±»SQL×¢Èë¹¥»÷¡£
Sql×¢Èë¹¥»÷µÄ·½Ê½£¬À´ÕâÀï¿´µÄͬ־ÃÇÓ¦¸ÃºÜÇå³þÁË£¬¾ÍÊÇÔÚÆ´½Ó×Ö·û´ ......
ÉÏһƪдµÄsql×¢ÈëµÄ»ù±¾ÔÀí£¬±¾À´Òª½Ó×ÅдÕâƪµÄ£¬µ«ÊÇÓÉÓÚʱ¼äµÄÔÒòһֱûÓÐд³É£¬½ñÌìÊÇÎåÒ»¼ÙÆÚ£¬×ÜËãÊÇÄܳé¿ÕддÁË¡£
×÷Ϊһ¸ö³ÌÐòÔ±£¬·À·¶sql×¢ÈëµÄµÚÒ»ÏßÊÇÓÉÎÒÃÇÀ´ÊØ»¤µÄ£¬Ö»ÒªÎÒÃÇÔÚ³ÌÐòÖÐÁôÉÙÐíµÄ©¶´£¬¾Í»á¸ø³ÌÐòÔöÇ¿°²È«ÌØÐÔ¡£ËùÒÔÎÒÃÇÒª×öµÄÊÇҪд°²È«µÄ³ÌÐò£¬·ÀÖ¹sql×¢ÈëÔÚ³ÌÐòÌåÏÖÔÚ²»ÒªÆ´½Ósql×Ö·û´®£¬ ......