1

Could anyone help on how to create a column with uuid generator field which would generate random numbers automatically while inserting the row.

shA.t
  • 16,580
  • 5
  • 54
  • 111
Selva
  • 49
  • 1
  • 3
  • 6
  • Possible duplicate of [Generating a UUID in Postgres for Insert statement?](https://stackoverflow.com/questions/12505158/generating-a-uuid-in-postgres-for-insert-statement) – shA.t Sep 06 '17 at 09:34

1 Answers1

5

If you install the uuid-ossp extension, you can e.g. use uuid_generate_v4() for the default value of such a column:

create table selva
(
  uid uuid default uuid_generate_v4(),
  ... other columns ..
);