본문 바로가기

Oracle/SQL Query

[QUERY]CLOB 데이터를 안 짤리고 다 보기

CLOB 데이터를 VARCHAR2 형식으로 보기


CLOB 데이터는 툴로 조회해서 보면 데이터가 짤려서 나온다. 그래서 매우 불편한데, 이 사항을 해결할 수 있는 방법을 찾아냄!!!


ORACLE이 기본적으로 제공하는 DBMS_LOB 패키지 함수를 사용하면 된다. 그중 SUBSTR함수를 사용하여 최초 몇바이트만 짤라서 다 뿌린다. 이런 의미의 함수로 보인다. 


이게 전체 데이터를 보는 정확한 방법은 아닐 수 있겠지만, 쉽게 원하는 데이터를 바로 볼수 있다는 점에 매우 좋다고 생각한다. 


참조 URL: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::NO::P11_QUESTION_ID:367980988799







Surrinder -- Thanks for the question regarding "Converting CLOBS TO VARCHAR", version 8.1.7

Submitted on 15-Mar-2001 11:11 Central time zone
Last updated 16-Sep-2011 14:11

You Asked

Can you give me a solution for converting CLOBS datatype to VARCHAR datatypes, all the 
documents I refer to talk about converting BLOBS to VARCHAR and when I try and apply the 
examples to CLOBS, get errors 

and we said...

dbms_lob.substr( clob_column, for_how_many_bytes, from_which_byte );


for example:

  select dbms_lob.substr( x, 4000, 1 ) from T;

will get me the first 4000 bytes of the clob.  Note that when using SQL as I did, the max 
length is 4000.  You can get 32k using plsql:


declare
   my_var long;
begin
   for x in ( select X from t ) 
   loop
       my_var := dbms_lob.substr( x.X, 32000, 1 );