Re: Primary Key...Is One Required?
Posted in 1999
Bonnie Annelin wrote:
>
> I have a question regarding primary keys for tables. Is it necessary to
> have a primary key for a table? According to Informix Documentation,
> if a primary key does not exist for a table, a primary key is composed
> of all columns taken together. Does this mean that Informix
> automatically generates a primary key? I do a database dump (dbschema)
> and do not see a primary key listed for my table. Also, I recently
> attended an Informix Class where the instructor said that Informix does
> not automatically generate a primary key. I'm now wondering whether
> or not I should create a serial record_num primary key for this table
> because if one is automatically generated out of every column (I have a
> large number of columns) and because primary keys are automatically
> indexed, this will be a very large/inefficient index.
>
> Thanks,
> Bonnie Annelin
Informix does not, to the best of my knowledge, automatically generate a
primary key, nor do you need one unless you wish to enforce referential
integrity. Informix does, however, automatically create a unique "rowid"
for each row in a table. This column does not appear in a table schema
but can be "selected" in a SQL statement eg select rowid from table.
Hope this helps
Gary Child