MD128
MD128

Reputation: 491

how to add record as last row of table (informix query)

i can select last record by this query

select first 1 idt from table1 order by id desc;

but i want to add a record ( id ++) to end of table in informix

Upvotes: 1

Views: 577

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269503

If I understand correctly, you want a SERIAL column in Informix. This is a column that automatically increments when you add a new value.

So, the table should be defined as:

create table table1 (
    id serial primary key,
    . . .
);

Then when you do an insert, leave out the id:

insert into table1 ( . . . )  -- all but id
    values ( . . . );

The id will be automatically incremented and inserted with the data.

Upvotes: 2

Related Questions