Search code examples
foreign-keysdb2maxlength

Maximum Length for a foreign key in DB2? (SQL0107N)


We have two installations of DB2.

When defining a foreign key with a long name, it works fine on one instance, but not on the other (we get a SQL0107N Name too long - max length is 18).

What is causing this different behaviour? Is there a parameter we can change or is it version dependant?


Solution

  • this seems to be version dependent. according to http://ptgmedia.pearsoncmg.com/images/0672326132/downloads/appd.pdf and http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0001029.htm , the limits for referential constraint names for the 7, 8, and 9 version of db2 are as follows:

    v7  8 bytes 
    v8  128 bytes
    v9  18 bytes
    

    these limits cannot be changed. so Adhering to the most restrictive case can help you to design application programs that are easily portable.