If you want to access the table with the identity column with the identity
column as key you need to add a primary key constraint to the table.
To make sure the generated identity value is always unique you need to
either add a primary key constraint or a unique key constraint or generate
an unique index over this column.
The easiest way to create a table with an identity column with an primary or
unique key constraint build over this column is to use iSeries Navigator -->
Database --> Schemas --> Select your schema --> Tables --> New.
CREATE TABLE MYSCHEMA/MYTABLE (
MYID INTEGER GENERATED ALWAYS AS IDENTITY (
START WITH 1 INCREMENT BY 1
NO MINVALUE NO MAXVALUE
NO CYCLE NO ORDER
CACHE 20 ),
MYCOL INTEGER NOT NULL DEFAULT 0 ,
... additional Columns/Fields ,
CONSTRAINT MYSCHEMA/MYPRIM PRIMARY KEY( MYID ) )
;
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von Pete Helgren
Gesendet: Sunday, 22. November 2009 02:42
An: Midrange Systems Technical Discussion
Betreff: Re: How do I create a file with an Identity Column field as the
key?
I have used STRSQL and have typically created the identity field with a
separate alter table statement after creating the other columns (not
sure *why * do it that way, now that I think about it). The ALTER
statement is similar to:
ALTER TABLE departments ADD COLUMN ID INTEGER NOT NULL generated
always as identity
Maybe I can't specify the "generated always as identity" in the STRSQL
prompt so that is why I added the identity field separately. I'd have
to play with it to find out, but the alter table syntax does work for me.
Pete
Booth Martin wrote:
How do I create a file with an Identity Column field as the key?
Can this be done with STRPDM and DDS?
As an Amazon Associate we earn from qualifying purchases.