<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 100  文章 - 50  trackbacks - 0
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(3)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    收藏夾

    我收藏的一些文章!

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    一、區(qū)別和定義

          LONG: 可變長的字符串數(shù)據(jù),最長2G,LONG具有VARCHAR2列的特性,可以存儲長文本一個表中最多一個LONG列
      LONG RAW: 可變長二進制數(shù)據(jù),最長2G
      CLOB:  字符大對象Clob 用來存儲單字節(jié)的字符數(shù)據(jù)
      NCLOB: 用來存儲多字節(jié)的字符數(shù)據(jù)
      BLOB: 用于存儲二進制數(shù)據(jù)
      BFILE: 存儲在文件中的二進制數(shù)據(jù),這個文件中的數(shù)據(jù)只能被只讀訪。但該文件不包含在數(shù)據(jù)庫內(nèi)。

            bfile字段實際的文件存儲在文件系統(tǒng)中,字段中存儲的是文件定位指針.bfile對oracle來說是只讀的,也不參與事務(wù)性控制和數(shù)據(jù)恢復(fù).
      
      CLOB,NCLOB,BLOB都是內(nèi)部的LOB(Large Object)類型,最長4G,沒有LONG只能有一列的限制

      要保存圖片、文本文件、Word文件各自最好用哪種數(shù)據(jù)類型?
      --BLOB最好,LONG RAW也不錯,但Long是oracle將要廢棄的類型,因此建議用BLOB。

    二、操作

    1、 get

    CLOB

     

    java 代碼
    1. //獲得數(shù)據(jù)庫連接   
    2.     Connection con = ConnectionFactory.getConnection();   
    3.     con.setAutoCommit(false);   
    4.     Statement st = con.createStatement();   
    5.     //不需要“for update”   
    6.     ResultSet rs = st.executeQuery("select CLOBATTR from TESTCLOB where ID=1");   
    7.     if (rs.next())   
    8.     {   
    9.         java.sql.Clob clob = rs.getClob("CLOBATTR");   
    10.         Reader inStream = clob.getCharacterStream();   
    11.         char[] c = new char[(int) clob.length()];   
    12.         inStream.read(c);   
    13.         //data是讀出并需要返回的數(shù)據(jù),類型是String   
    14.         data = new String(c);   
    15.         inStream.close();   
    16.     }   
    17.     inStream.close();   
    18.     con.commit();   
    19.     con.close();   
    20.    

     

    BLOB
    java 代碼
    1. //獲得數(shù)據(jù)庫連接   
    2.     Connection con = ConnectionFactory.getConnection();   
    3.     con.setAutoCommit(false);   
    4.     Statement st = con.createStatement();   
    5.     //不需要“for update”   
    6.     ResultSet rs = st.executeQuery("select BLOBATTR from TESTBLOB where ID=1");   
    7.     if (rs.next())   
    8.     {   
    9.         java.sql.Blob blob = rs.getBlob("BLOBATTR");   
    10.         InputStream inStream = blob.getBinaryStream();   
    11.         //data是讀出并需要返回的數(shù)據(jù),類型是byte[]   
    12.         data = new byte[input.available()];   
    13.         inStream.read(data);   
    14.         inStream.close();   
    15.     }   
    16.     inStream.close();   
    17.     con.commit();   
    18.     con.close();   

     

    2、 put

    CLOB
    java 代碼
    1. //獲得數(shù)據(jù)庫連接   
    2.     Connection con = ConnectionFactory.getConnection();   
    3.     con.setAutoCommit(false);   
    4.     Statement st = con.createStatement();   
    5.     //插入一個空對象empty_clob()   
    6.     st.executeUpdate("insert into TESTCLOB (ID, NAME, CLOBATTR) values (1, "thename", empty_clob())");   
    7.     //鎖定數(shù)據(jù)行進行更新,注意“for update”語句   
    8.     ResultSet rs = st.executeQuery("select CLOBATTR from TESTCLOB where ID=1 for update");   
    9.     if (rs.next())   
    10.     {   
    11.         //得到j(luò)ava.sql.Clob對象后強制轉(zhuǎn)換為oracle.sql.CLOB   
    12.         oracle.sql.CLOB clob = (oracle.sql.CLOB) rs.getClob("CLOBATTR");   
    13.         Writer outStream = clob.getCharacterOutputStream();   
    14.         //data是傳入的字符串,定義:String data   
    15.         char[] c = data.toCharArray();   
    16.         outStream.write(c, 0, c.length);   
    17.     }   
    18.     outStream.flush();   
    19.     outStream.close();   
    20.     con.commit();   
    21.     con.close();   
    22.   
    BLOB
    java 代碼
    1. //獲得數(shù)據(jù)庫連接   
    2.     Connection con = ConnectionFactory.getConnection();   
    3.     con.setAutoCommit(false);   
    4.     Statement st = con.createStatement();   
    5.     //插入一個空對象empty_blob()   
    6.     st.executeUpdate("insert into TESTBLOB (ID, NAME, BLOBATTR) values (1, "thename", empty_blob())");   
    7.     //鎖定數(shù)據(jù)行進行更新,注意“for update”語句   
    8.     ResultSet rs = st.executeQuery("select BLOBATTR from TESTBLOB where ID=1 for update");   
    9.     if (rs.next())   
    10.     {   
    11.         //得到j(luò)ava.sql.Blob對象后強制轉(zhuǎn)換為oracle.sql.BLOB   
    12.         oracle.sql.BLOB blob = (oracle.sql.BLOB) rs.getBlob("BLOBATTR");   
    13.         OutputStream outStream = blob.getBinaryOutputStream();   
    14.         //data是傳入的byte數(shù)組,定義:byte[] data   
    15.         outStream.write(data, 0, data.length);   
    16.     }   
    17.     outStream.flush();   
    18.     outStream.close();   
    19.     con.commit();   
    20.     con.close();
    posted on 2010-08-06 14:20 fly 閱讀(906) 評論(0)  編輯  收藏 所屬分類: 數(shù)據(jù)庫學(xué)習(xí)
    主站蜘蛛池模板: 成年网站免费视频A在线双飞| 四虎永久免费网站免费观看| 亚洲乱码中文字幕在线| 全亚洲最新黄色特级网站 | 亚洲永久网址在线观看| 又黄又大又爽免费视频| 久久国产精品2020免费m3u8| 亚洲色最新高清av网站| 国产v亚洲v天堂无码网站| 成年女人免费视频播放体验区| 有色视频在线观看免费高清在线直播 | 免费视频精品一区二区三区| 国产成人精品亚洲2020| 亚洲精品无码久久千人斩| 成人毛片18女人毛片免费| 国产永久免费高清在线| 亚洲国产精品一区二区三区在线观看| 亚洲一区精品伊人久久伊人| 黄瓜视频影院在线观看免费| 丝袜捆绑调教视频免费区| 亚洲精品一卡2卡3卡四卡乱码| 久热综合在线亚洲精品| 免费在线观看视频a| 免费毛片a在线观看67194| 免费看少妇高潮成人片| 美女视频黄频a免费大全视频| 亚洲精品无码久久毛片波多野吉衣| 免费人妻无码不卡中文字幕18禁| 最近2019中文字幕免费大全5 | 亚洲国产成人综合| 亚洲综合图色40p| 国产免费私拍一区二区三区| 国产精品久久免费| 免费福利在线视频| 亚洲精品黄色视频在线观看免费资源 | 亚洲理论片中文字幕电影| 亚洲综合国产一区二区三区| 国产精品四虎在线观看免费| 国产成人精品免费视频动漫| 女人体1963午夜免费视频| 国产黄色片免费看|