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 can I use PostgreSQL XML functions to manipulate XML data?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How can I set a PostgreSQL interval to zero?
- How do I use PostgreSQL with Qt?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How can I use PostgreSQL and ZFS snapshots together?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can I use PostgreSQL's "zero if null" feature?
- How can I integrate PostgreSQL with Yii2?
- How can I use PostgreSQL with YAML?
See more codes...