sqlinformixmultiple-select-query

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


Solution

  • 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.