If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > The row length of the table exceeded a limit of "32677" bytes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-05-08, 06:28
chas_dba chas_dba is offline
Registered User
 
Join Date: Sep 2003
Posts: 33
Question The row length of the table exceeded a limit of "32677" bytes

I am getting the above message while creating a table with200 columns with VARCHAR(256) in DB2 9.5 LUW. I have overcome this by changing the data type to LONG VARCHAR.
But the problem is the literature in fixpack 1 for 9.5 says that the datatype LONG VARCHAR is deprecated. What is the way out of this problem.
Please help folks.
__________________
bs
Reply With Quote
  #2 (permalink)  
Old 11-05-08, 06:38
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Right, LONG VARCHAR because it is deprecated (for quite a while already). One alternative is to use CLOBs instead.

However, I would like to understand why you need 200 VARCHAR(256) columns. What kind of information is stored there? I am asking because it rather looks like a data model issue.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 11-05-08, 06:43
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
The replacement for LONG VARCHAR is CLOB. Both are stored in a separate area (not in the row on the data page with other columns) which is why it does not impact the 32677 page size limit (not counting page overhead). But performance will suffer since neither of these data types uses the bufferpool to cache pages, and all read and write I/O is synchronous to disk. Make sure you have file caching on for any tablespace with a LOB column (best to have a separate tablespace for LONG objects).

You would be better off performance-wise if you created two tables without LOB’s or LONG VARCHAR and linked them together, but you will need more bufferpool space for the 32K page sizes and real memory to support it (do not use virtual memory for bufferpools).
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #4 (permalink)  
Old 11-05-08, 06:44
chas_dba chas_dba is offline
Registered User
 
Join Date: Sep 2003
Posts: 33
Question

Thanks for revert. Well, i may not be able to answer your question as this db is getting migrated from Oracle. Model questions are beyond me as this is a product in use for while supported on Oracle. Recently there is a move to enhance this product for support on db2 as well.

Well, coming to CLOBs.. i am still getting the failure message.
__________________
bs
Reply With Quote
  #5 (permalink)  
Old 11-05-08, 06:49
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
I think you need to post the create table DDL and the exact error message. I would put the LONG data in a separate tablespace.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #6 (permalink)  
Old 11-05-08, 07:05
chas_dba chas_dba is offline
Registered User
 
Join Date: Sep 2003
Posts: 33
Question

Well i could overcome the error by replacing CLOB with CLOB(256). I am not sure if this would call for any code changes in the application. Also the requirement is not to alter tables structure.
Can somebody point out any trivial issues associated with this. Like support of CLI Drivers and dynamic sql etc.
__________________
bs
Reply With Quote
  #7 (permalink)  
Old 11-05-08, 07:10
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
In DB2 you must specify the maximum length, even in a CLOB. That is probably what the error is saying. It will not affect the code.

You need to make sure that you specify that the data on the CLOB is logged, because I think LOB's are not logged by default (not sure). Please refer to the SQL Reference manual Vol 2 for details on create table.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #8 (permalink)  
Old 11-05-08, 08:06
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
CLOB and VARCHAR data types are treated differently when the database is accessed via JDBC. I suspect the same may be true with CLI access as well. Before you do any further changes try to test the application with the modified table.

One workaround would be to create a view that casts CLOB columns to VARCHAR "on the fly". Obviously, there will be some performance overhead.
Reply With Quote
  #9 (permalink)  
Old 11-06-08, 15:15
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
I would myself indeed also go for the "split in two tables" solution.

Let's say you need
Code:
CREATE TABLE t
( col001 VARCHAR(256) PRIMARY KEY,
  col002 VARCHAR(256),
 ...
  col200 VARCHAR(256))
Instead, create the following three objects:
Code:
CREATE TABLE t1
( col000 VARCHAR(256) PRIMARY KEY,
  col002 VARCHAR(256),
 ...
  col100 VARCHAR(256)) ;
CREATE TABLE t2
( col001 VARCHAR(256) PRIMARY KEY,
  col101 VARCHAR(256),
  col102 VARCHAR(256),
 ...
  col200 VARCHAR(256)) ;
CREATE VIEW t AS
(SELECT col001, ..., col200 FROM t1 INNER JOIN t2 ON t1.col000 = t2.col001)
Reading applications will not see the difference. For writing applications you'll need INSTEAD OF triggers.

Alternatively (if that's an option), reduce the max. size of some of the columns such that the sum of the sizes is small enough. (Account for 1 additional byte per column without NOT NULL, and 2 additional bytes per VARCHAR column.)
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #10 (permalink)  
Old 11-06-08, 18:06
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by Peter.Vanroose
Reading applications will not see the difference. For writing applications you'll need INSTEAD OF triggers.
I think it could be a problem if the result set is wider than fits on a 32K page. But that would depend on the actual length of the data stored in the VARCHAR's.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On