Re: Automatic creation of PK with Triggers ...
Posted in 1998
Oliver Schmitt wrote:
>
> My Problem :
>
> I want to create the primary keys of my tables automaticaly.
>
> I want to create them by a trigger (before insert). But it doesn't work
> ...
>
> Is there another method to create the PK's automaticaly ??
>
> Thanks for help :
>
> OLLI
You just decalare a column (or columns) of your table to be a primary
key and the database does it for you. It's that simple! An example:
CREATE TABLE mytable
(
mycolumn CHAR(4),
myothercolumn CHAR(40),
mylastcolumn DECIMAL,
PRIMARY KEY (mycolumn) CONSTRAINT mytable_key
);
The "CONSTRAINT mytable_key" part is optional but recommended.
I suggest you read the "Informix Guide to SQL: Tutorial" if any of this
is not clear. Informix manuals are good. They are definitely worth
reading.
--
Peter Lancashire
Information Systems Specialist, Bayer plc
Eastern Way, Bury St Edmunds, Suffolk, IP32 7AH, UK
Tel: +44-1635-562258, Fax: +44-1635-562281
Mail: Peter.Lancashire.PL1@bayer.co.uk
---
My Internet plumbing does not allow me to mail and post news together.
Sorry.
All opinions are my own and not those of Bayer plc.
---
Join Infuse, the UK Informix User Group at http://www.infuse.org.uk/