×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Best datatype?
3

Best datatype?

Best datatype?

(OP)
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?

RE: Best datatype?

That's interesting - I didn't realise there was a limitation on how many LONG columns you could have in one table.

Off the top of my head I can think of two possible approaches to this problem:

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.

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.

Hope this is understandable and that I understood your question properly - let us know how you get on.

Mike

RE: Best datatype?

3
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.

Also, while in V7 VARCHAR2s were limited to 2000 characters, in V8 this is increased to 4000.

RE: Best datatype?

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close