Selva
Selva

Reputation: 49

Creating default UUID generator in postgres

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

Upvotes: 1

Views: 6788

Answers (1)

user330315
user330315

Reputation:

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 ..
);

Upvotes: 5

Related Questions