The PostgreSQL provides Universally Unique Identifier -UUID data type and related functions.
In the previous post, I have already shared the truth about Universally Unique Identifier - UUID.
You can visit this article here.
PostgreSQL provides two extensions.
1. uuid-ossp 2. pgcrypto.
You can install this extension using this script.
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS pgcrypto;
I am using pgcrypto extension for generating a UUID.
Below is a small demonstration:
Generate UUID using gen_random_uuid():
Create a sample table with UUID Data type:
CREATE TABLE tbl_UUIDSample
MyUUID UUID PRIMARY KEY DEFAULT gen_random_uuid()
Insert sample data:
INSERT INTO tbl_UUIDSample (Name)
SELECT *FROM tbl_UUIDSample;
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.