Results 1 to 2 of 2

Thread: SQL5051 error

  1. #1
    Join Date
    Jan 2003
    Location
    Kuala Lumpur, Malaysia
    Posts
    6

    Unanswered: SQL5051 error

    Hello,

    I get a SQL5051 error when I try to alter a table to include PK's. My syntax is as follows :

    ALTER TABLE <LIBRARY_NAME.TABLE_NAME>
    ADD CONSTRAINT <PK_NAME> PRIMARY KEY
    <COLUMN_NAME>

    I am using JDBC (IBM Toolbox for Java) on a DB2/400 V5R1.

    I checked the documentation and it specified the following:

    "A constraint name was qualified by a name that is not the same as the qualifier for the table. A constraint for a table must be qualified by the same collection as the table. If not explicitly qualified, a constraint name is implicitly qualified by the default collection ID, if one is specified. Otherwise, the constraint name is implicitly qualified by the authorization ID for SQL names and by the qualifier of the table name for system names. "

    Can anybody help?

  2. #2
    Join Date
    Mar 2003
    Posts
    33

    Re: SQL5051 error

    You must explicitly qualify the object in the schema with
    "<schema-name>" (same as tables schema) or remove "<qualifier>" from the object name.

    ALTER TABLE <SCHEMA.TABLE_NAME>
    ADD CONSTRAINT <PK_NAME> PRIMARY KEY
    <COLUMN_NAME>
    or

    ALTER TABLE <TABLE_NAME>
    ADD CONSTRAINT <PK_NAME> PRIMARY KEY
    <COLUMN_NAME>
    -r-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •