Could anyone help on how to create a column with uuid generator field which would generate random numbers automatically while inserting the row.
Asked
Active
Viewed 6,083 times
1
-
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 Answers
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 ..
);
a_horse_with_no_name
- 497,550
- 91
- 775
- 843