Use of UUID in PostgreSQL

Source: Internet
Author: User
Tags function definition uuid

This article provides a total of two methods:

1. Use the Create extension command

create extension "uuid-OSSP"  

After the installation extension is successful, you can query by UUID_GENERATE_V4 () or UUID_GENERATE_V1 ()

Select uuid_generate_v4 ()

2. If PostgreSQL is installed by default, it is not with the UUID function, in order to generate a UUID, we can build on the client.

The function definition already exists in PostgreSQL's installation directory, and all we have to do is import it in.

Under the Share/contrib of the installation directory, you can find uuid-ossp.sql and use the command

psql-d pisces-u postgres-f d:/service/postgresql/9.0/share/contrib/uuid-ossp.sql  

Parameter description:

-D: Database name

-U: User name

-F: File to import

If the screen is displayed so that it is correct

You can then execute the query statement in Method 1.

Select uuid_generate_v4 ();  

For more information about UUID, you can refer to the official documentation of PostgreSQL.

Use of UUID in PostgreSQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.