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

546 Views Asked by At

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

1

There are 1 best solutions below

1
Gordon Linoff On BEST ANSWER

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.