0

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

1
  • In Postgres 18+, call uuidv7for a Version 7 UUID value that enables efficient indexing. See my Answer on the original of this duplicate Question. Commented Oct 11 at 6:43

1 Answer 1

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 ..
);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.