For test purposes, I would like to insert a large amount of data (approx. 1 MByte) into an Oracle CLOB column. In order to keep the test simple, I want to do that without having to write a test program using C++ or Java; instead, I want to use SQL*PLus.
Does Oracle’s SQL syntax offer any possibility to do that? I.e. instead of the EMPTY_CLOB() function, I would need something like MAKE_CLOB('x', 1000000) that makes a CLOB by repeating a character 1,000,0000 times.
(Note: I specifically do not want to insert the CLOB by using a SELECT clause within the INSERT statement to select a large CLOB value from another record. The reason is that I want to make sure that my test only covers a CLOB-write operation, but not a CLOB-read operation.)
It’s easy enough to do with an anonymous block. We have to use a loop, because the 32K is the largest string we can use in PL/SQL. This ran on Oracle 11g; with very old versions of the database you have to use the the DBMS_LOB functionality instead
And lo!