postgresqlHow do I generate a UUID in PostgreSQL?
A UUID (Universally Unique Identifier) is a 128-bit number used to identify information in computer systems. In PostgreSQL, you can generate a UUID using the uuid_generate_v4()
function.
Example code
SELECT uuid_generate_v4();
Example output:
d1f9f02b-721a-4a0f-a2b4-2b9b7f9d2d4e
The code consists of the following parts:
SELECT
: This is the SQL command used to select data from a table.uuid_generate_v4()
: This is the function used to generate a UUID in PostgreSQL.
You can also generate a UUID using other functions such as uuid_generate_v1()
, uuid_generate_v3()
, and uuid_generate_v5()
.
For more information, please refer to the following links:
More of Postgresql
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How do I parse XML data using PostgreSQL?
- How can Zalando use PostgreSQL to improve its software development?
- How do I use PostgreSQL variables in my software development project?
- How do I use PostgreSQL's XMIN and XMAX features?
- How can I use PostgreSQL and ZFS snapshots together?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How can I use PostgreSQL and Node.js together to develop a software application?
- How can I set a PostgreSQL interval to zero?
- How do I use PostgreSQL and ZFS together?
See more codes...