Working with very large text data and CLOB column

前端 未结 3 1596
青春惊慌失措
青春惊慌失措 2020-12-06 03:30

According to documentation CLOB and NCLOB datatype columns, can store up to 8 terabytes of character data.

I have text, which contains 100 000 character, how can I

相关标签:
3条回答
  • 2020-12-06 03:50

    You should use the dbms_lob package, the procedure to add some string to the clob is dbms_lob.append.

    DBMS_LOB documentation

    declare
      c1 clob;
      c2 varchar2(32000);
    begin
      c1 := 'abc';
      c2 := 'text, which contains 32 000 characters';
      dbms_lob.append(c1, c2);
      c2 := 'some more text, which contains 32 000 characters';
      dbms_lob.append(c1, c2);
      insert into t1 values (c1);
    end;
    
    0 讨论(0)
  • 2020-12-06 03:51

    I found this question while Googling how to append data to a CLOB. For my particular problem, I'm using a legacy PL/SQL system where I can't make use of the dbms_lob package, so I thought that I would share my answer for the benefit of others in my situation.

    Solution: Use Oracle's CONCAT function in aSELECTquery, theCONCATfunction works for theCLOB` data type. For example (using @AlenOblak's example):

    declare
      c1 clob;
      c2 varchar2(32000);
    begin
      c1 := 'abc';
      c2 := 'text, which contains 32 000 characters';
      SELECT CONCAT(c1, c2) INTO c1 FROM DUAL;
      c2 := 'some more text, which contains 32 000 characters';
      SELECT CONCAT(c1, c2) INTO c1 FROM DUAL;
      insert into t1 values (c1);
    end;
    

    Hope that helps.

    0 讨论(0)
  • 2020-12-06 04:02

    I have resolve this case with Data Import feature in Oracle SQL Developer:

    1. Make .dsv file with your large string and other attributes.
    2. Just rclick on table and choose 'Data Import'
    3. Choose your file
    4. In Data Import Wizard Step1: select rigth Delimeter, Line Terminator, Row Limit, Encloser characters etc.
    5. Step2: Import Method=Insert, Step3: Map file and table columns to each other
    6. Step4: Run the Data Import
    0 讨论(0)
提交回复
热议问题