how to add a new row to a table with a primary key

  • I am trying to add a new row to a table

    here is my sql

    insert into table (column2, column3, column4)

    values (1, 2, 3)

    I leave out column1, because it's a primary key. but I get an error message. Please help.

  • What is your table structure and what is the actual error message you are receiving?

  • Hi there,

    Can you post your query? You cant insert if you have primary key, it must always have, unless you dont have a primary key set in you database, but you can manually create you own primary key without tagging any primary key.

    Regards,

    Clint

  • It sounds like there may be some confusion between a "primary key" and a column with the property "identity". These are not the same thing..

    If the column is marked as an identity column it should not (normally) be listed in the list of columns when you insert and the system will generate the value for you.

    If the column is a PK (but not an identity) then you must give the column a value.

    The critical bit is that making it an identity column does NOT automatically make it a key of any sort. The full DDL would make giving the exact answer easy!

    Mike John

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply