I need to create a table that has multiple columns that store large amounts of text. Oracle8 only handles one 'LONG' datatype per table. What is the best datatype to use in this situation?
That's interesting - I didn't realise there was a limitation on how many LONG columns you could have in one table.<br>
<br>
Off the top of my head I can think of two possible approaches to this problem:<br>
<br>
1) Store multiple objects in one LONG column in a format your application understands. You could do this is a couple of ways - a LONG column is just a big long stream of bytes so try writing all your text objects to a single column separated by an "end-of-object" marker. Or you could store the lenghth of each object in another column and retrieve multiple LONG objects from the column in that way.<br>
<br>
2) Fake It - haven't tried this. Have multiple tables each with a LONG column and a primary key which are then combined into a single view. In later versions or Oracle you can create views which are updateable.<br>
<br>
Hope this is understandable and that I understood your question properly - let us know how you get on.<br>
<br>
Mike<br>
First, I would not use LONG columns but LOBs (Large OBjects), which are new to V8. BLOBs are for binary data, and CLOBs are for character data. There are also NCLOBs for multibyte character sets and BFILE, which is a pointer to an external file. BLOBs, CLOBs and NCLOBs can be up to 4Gb in size and you can have multiple LOBs per table (you can still have only one LONG data column per table). Data for these data types are stored within the database. Files referenced by BFILE are only limited the operating system. There are a number of built-in functions and procedures in the DBMS_LOB package that can be used to work with LOBs, including READ, SUBSTR, INSTR, GETLENGTH, COMPARE, WRITE, APPEND, ERASE, TRIM, and COPY. Also, the LONG datatype is going away in the future, so I would not start using it now.<br>
<br>
Also, while in V7 VARCHAR2s were limited to 2000 characters, in V8 this is increased to 4000.
First, I would not use LONG columns but LOBs (Large OBjects), which are new to V8. BLOBs are for binary data, and CLOBs are for character data. There are also NCLOBs for multibyte character sets and BFILE, which is a pointer to an external file. BLOBs, CLOBs and NCLOBs can be up to 4Gb in size and you can have multiple LOBs per table (you can still have only one LONG data column per table). Data for these data types are stored within the database. Files referenced by BFILE are only limited the operating system. There are a number of built-in functions and procedures in the DBMS_LOB package that can be used to work with LOBs, including READ, SUBSTR, INSTR, GETLENGTH, COMPARE, WRITE, APPEND, ERASE, TRIM, and COPY. Also, the LONG datatype is going away in the future, so I would not start using it now.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.