How to start my id column from 1 ?
My tabel is :
id | origin | destination | duration
----+-------------+-------------+----------
6 | Paris | New York | 540
7 | Tokyo | Shanghai | 185
8 | Seoul | Mexico City | 825
9 | Mexico City | Lima | 350
10 | Hong Kong | Shanghai | 130
Here id is my SERIAL KEY and PRIMARY KEY.
And I am using PostgreSQL.
Serial columns are linked to a SEQUENCE. If it is an automatically generated sequence it will be called something like tablename_columnname_id_seq. You can alter a sequences next value using the function SETVAL(sequence_name, number).
However, as you have existing data in the system you will end up with conflicts when the sequence hits 6. You have to update the id column of your existing table, then set the sequence to the biggest value so the next table entry continues the sequence correctly.