Sunday , December 22 2024

Universal Unique İdentifier (UUID) Data Type In PostgreSQL

 

Uuid is the abbreviation for “universal unique identifier”. It consists of 36 characters, a set of numbers and letters, and its most important feature is: Its extremely unique.

To use this feature on PostgreSQL, we need to install uuid-ossp extension.

We can install extension with the following command;

 

After running the command above, we see that it was created as follows.

 

We created the Extension.

Let’s create a uuid value using the uuid_generate_v1 () function in order to test this data type.

The uuid_generate_v1 () function creates the new UUID, based on the combination of the computer’s mac address, the current timestamp, and the random value.

 

We are creating a table named t1 and we are creating a UUID data type column for this table.

 

Let’s insert some data into this table and look at the results.

 

We can see the uuid values generated automatically as a result of the insert.

 

 

 

Loading

About Faruk Erdem

Leave a Reply

Your email address will not be published. Required fields are marked *