How to store unlimited characters in Oracle 11g? How to store unlimited characters in Oracle 11g? oracle oracle

How to store unlimited characters in Oracle 11g?


If a blob is what you need convince your dba it's what you need. Those data types are there for a reason and any roll your own implementation will be worse than the built in type.

Also you might want to look at the CLOB type as it will meet your needs quite well.


You could follow the way Oracle stored their stored procedures in the information schema. Define a table called text columns:

CREATE TABLE MY_TEXT (IDENTIFIER INT, LINE       INT,TEXT       VARCHAR2 (4000),PRIMARY KEY (INDENTIFIER, LINE));

The identifier column is the foreign key to the original table. The Line is a simple integer (not a sequence) to keep the text fields in order. This allows keeping larger chunks of data

Yes this is not as efficient as a blob, clob, or LONG (I would avoid LONG fields if at all possible). Yes, this requires more mainenance, buf if your DBAs are dead set against managing CLOB fields in the database, this is option two.

EDIT:

My_Table below is where you currently have the VARCHAR column you are looking to expand. I would keep it in the table for the short text fields.

CREATE TABLE MY_TABLE (INDENTIFER INT,OTHER_FIELD VARCHAR2(10),REQUIRED_TEXT VARCHAR(4000),PRIMERY KEY (IDENTFIER));

Then write the query to pull the data join the two tables, ordering by LINE in the MY_TEXT field. Your application will need to split the string into 2000 character chunks and insert them in line order.

I would do this in a PL/SQL procedure. Both insert and select. PL/SQL VARCHAR strings can be up to 32K characters. Which may or may not be large enough for your needs.

But like every other person answering this question, I would strongly suggest making a case to the DBA to make the column a CLOB. From the program perspective this will be a BLOB and therefore simple to manage.


You said no BLOB or LONG... but what about CLOB? 4GB character data.