OracleÖеÄRawÀàÐͽâÊÍ
RAW£¬ÀàËÆÓÚCHAR£¬ÉùÃ÷·½Ê½RAW(L)£¬LΪ³¤¶È£¬ÒÔ×Ö½ÚΪµ¥Î»£¬×÷ΪÊý¾Ý¿âÁÐ×î´ó2000£¬×÷Ϊ±äÁ¿×î´ó32767×Ö½Ú¡£
¡¡¡¡LONG RAW£¬ÀàËÆÓÚLONG£¬×÷ΪÊý¾Ý¿âÁÐ×î´ó´æ´¢2G×Ö½ÚµÄÊý¾Ý£¬×÷Ϊ±äÁ¿×î´ó32760×Ö½Ú
¡¡¡¡½¨±í²Ù×÷:
¡¡¡¡create table raw_test (id number, raw_date raw(10));
¡¡¡¡²åÈërawÊý¾Ý²Ù×÷:
¡¡¡¡insert into raw_test values (1, hextoraw('ff'));
¡¡¡¡insert into raw_test values (utl_raw.cast_to_raw('051'));
¡¡¡¡É¾³ý±í²Ù×÷:
¡¡¡¡drop table raw_test;
¡¡¡¡µ±Ê¹ÓÃHEXTORAWʱ£¬»á°Ñ×Ö·û´®ÖÐÊý¾Ýµ±×÷16½øÖÆÊý¡£¶øʹÓÃUTL_RAW.CAST_TO_RAWʱ£¬Ö±½Ó°Ñ×Ö·û´®ÖÐÿ¸ö×Ö·ûµÄASCIIÂë´æ·Åµ½RAWÀàÐ͵Ä×Ö¶ÎÖÐ.
¡¡¡¡¿ÉÒÔʹÓÃdumpº¯Êý£¬²éѯ´æ´¢Çé¿ö£º
¡¡¡¡select id,raw_date, dump(raw_date, 16) dump_raw from raw_test;
¡¡¡¡OracleÖÐRAWºÍVarchar2³£ÓõÄÁ½¸öת»»º¯Êý
¡¡¡¡1. UTL_RAW.CAST_TO_RAW
¡¡¡¡¸Ãº¯Êý°´ÕÕȱʡ×Ö·û¼¯£¨Ò»°ãΪGB2312£©£¬½«VARCHAR2×Ö·û´®×ª»»ÎªRAW¡£
¡¡¡¡insert into cmpp_submit (dest_terminal_id,msg_content) values('13001081371',UTL_RAW.CAST_TO_RAW('ÄúºÃ£¡'));
¡¡¡¡2. UTL_RAW.CAST_TO_VARCHAR2
¡¡¡¡¸Ãº¯Êý°´ÕÕȱʡ×Ö·û¼¯ºÏ£¨Ò»°ãΪGB2312£©£¬½«RAWת»»ÎªVARCHAR2¡£
¡¡¡¡select UTL_RAW.CAST_TO_VARCHAR2(msg_content) from cmpp_deliver;
¡¡¡¡ÆäʵRAWºÍVARCHARÊÇÀàËƵÄ,Ö»ÊÇ´æ´¢ÔÚRAWÀïµÄÊǶþ½øÖÆÖµ,ÔÚÈκÎʱºò²»»á×ö×Ô¶¯µÄ×Ö·û¼¯×ª»»,ÕâÊÇRAWºÍVARCHARµÄ²»Í¬,RAWÖ»ÊÇÒ»ÖÖÍⲿÀàÐÍ,ÆäÄÚ²¿´æ´¢ÊÇVARRAW
¡¡¡¡VARCHARµÄOracleÄÚ²¿¶¨ÒåÊÇ:struct { ub2 len; char arr[n] }
¡¡¡¡VARRAWµÄORACLEÄÚ²¿¶¨ÒåÊÇ: struct { ub2 len; unsigned char arr[n] }
Ïà¹ØÎĵµ£º
Oracle³£Ó÷ÖÎöº¯Êý
ROW_NUMBER
·µ»ØÓÐÐò×éÖÐÒ»ÐеÄÆ«ÒÆÁ¿£¬´Ó¶ø¿ÉÓÃÓÚ°´Ìض¨±ê×¼ÅÅÐòµÄÐкÅ
row_number() over(partition by ... order by ...)
RANK
¸ù¾ÝORDER BY×Ó¾äÖбí´ïʽµÄÖµ£¬´Ó²éѯ·µ»ØµÄÿһÐУ¬¼ÆËãËüÃÇÓëÆäËüÐеÄÏà¶ÔλÖá£×éÄÚµÄÊý¾Ý°´ORDER BY×Ó¾äÅÅÐò£¬È»ºó¸øÿһÐи³Ò»¸öºÅ£¬´Ó¶øÐγÉÒ»¸öÐòÁУ¬¸ÃÐòÁ ......
ÈçºÎÔ¶³ÌÅжÏOracleÊý¾Ý¿âµÄ°²×°Æ½Ì¨
¡¡¡¡select * from v$version;
¡¡¡¡²é¿´±í¿Õ¼äµÄʹÓÃÇé¿ö
¡¡¡¡select sum(bytes)/(1024*1024) as free_space,tablespace_name
¡¡¡¡from dba_free_space
¡¡¡¡group by tablespace_name;
¡¡¡¡SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES ......
spool d:\deletetb.sql;
select 'delete ' || table_name || ' where to_char(col,'||'''yyyy'''||')='||'''2007'''||';'
from user_tables
where table_name in (select 'HS_' || lpad(rownum, '2', '0')
from dual
  ......
À´Ô´ÓÚhttp://hi.baidu.com/edeed/blog/item/33576327d1b73d00918f9dd4.html
±¾ÊÓͼ×ÔÆô¶¯¼´±£³Ö²¢¼Ç¼¸÷»Ø¹ö¶Îͳ¼ÆÏî¡£ÔÚѧϰ±¾ÊÓͼ֮ǰ£¬ÎÒÃÇÏÈÀ´Á˽âһϻعö¶Î(rollback segment)µÄÏà¹Ø¸ÅÄ
»Ø¹ö¶Î¸ÅÊö
»Ø¹ö¶ÎÓÃÓÚ´æ·ÅÊý¾ÝÐÞ¸Ä֮ǰµÄÖµ£¨°üÀ¨Êý¾ÝÐÞ¸Ä֮ǰµÄλÖúÍÖµ£©¡£»Ø¹ö¶ÎµÄÍ·²¿°üº¬ÕýÔÚʹÓõĸûعö¶ÎÊÂÎñµÄÐ ......
1.LOWER(str) Ç¿ÖÆСд
2.UPPER(str) Ç¿ÖÆ´óд
3.INITCAP(str) ÿ¸öµ¥´ÊÊ××Öĸ´óд
ʾÀý£º
SQL> select initcap('my_boy') from dual; --·µ»Ø"My_Boy"
×¢Ò⣺µ¥´ÊÖ®¼äÓÃÏ»®Ïߣ¨"_"£©·Ö¸î
4.CONCAT(str1,str2£©Á¬½Óº¯Êý,Á¬½Óstr1ºÍstr2×Ö·û´®
5.SUBSTR(string,a[,b])·µ»ØstringµÄÒ»²¿·Ö£¬aºÍbÒÔ×Ö·ûΪµ¥Î»¡£´Ó× ......