Add auto increment column to existing table ordered by date
问题 I have an existing table named "tickets" in database with columns: id (string, Primary Key, contains UUID like e6c49164-545a-43a1-845f-73c5163962f2) date (biginteger, stores epoch) status (string) I need to add new auto increment column ticket_id but the values to be generated should be according to "date" column value. I tried this: ALTER TABLE "tickets" ADD COLUMN "ticket_id" SERIAL; The problem is, it is generating "ticket_id" values in some weird order, looks like it is based on "id"