Using uuid-cb in Managed Service for Greenplum®
The uuid-cb
extension exports functions for generating and validating unique IDs in compliance with the Russian Central Bank requirements:
uuid_cb_generate()
: Generates atext
value that is a unique ID in the format required by the Russian Central Bank.uuid_cb_valid(text)
: Returns aboolean
value that indicates if a text argument is a unique ID in the format required by the Russian Central Bank.
Installing the uuid-cb extension in a Greenplum® cluster
-
Connect to the database as the owner or a user with the
CREATE
permission and run the command:CREATE EXTENSION "uuid-cb";
-
Make sure that the extension is installed:
SELECT extname FROM pg_extension;
Usage example
-
Create a table with unique IDs and data such as:
CREATE TABLE uid_tbl ( uid TEXT NOT NULL DEFAULT uuid_cb_generate() CHECK (uuid_cb_valid(uid) = true), data INTEGER NOT NULL, PRIMARY KEY (uid) ) DISTRIBUTED BY(uid);
The unique IDs in the format required by the Russian Central Bank will be generated in the
uid
column as default values. A check doesn't allow inserting values that are not unique IDs in the format required by the Russian Central Bank. -
Insert the test data into the
data
column:INSERT INTO uid_tbl (data) SELECT d FROM generate_series(1, 10) d;
For each command run, pseudorandom ID values are generated.
-
Check the generated data:
SELECT * FROM uid_tbl;
Result:
uid | data ----------------------------------------+------ 4b68f587-6739-11ed-80d4-1b1dc5b7125e-1 | 8 4b68f589-6739-11ed-80d4-1b1dc5b7125e-1 | 10 4b68f581-6739-11ed-80d4-1b1dc5b7125e-1 | 2 4b68f583-6739-11ed-80d4-1b1dc5b7125e-1 | 4 4b68f585-6739-11ed-80d4-1b1dc5b7125e-1 | 6 4b68f588-6739-11ed-80d4-1b1dc5b7125e-9 | 9 4b68f580-6739-11ed-80d4-1b1dc5b7125e-9 | 1 4b68f582-6739-11ed-80d4-1b1dc5b7125e-9 | 3 4b68f584-6739-11ed-80d4-1b1dc5b7125e-9 | 5 4b68f586-6739-11ed-80d4-1b1dc5b7125e-9 | 7 (10 rows)
Greenplum® and Greenplum Database® are registered trademarks or trademarks of VMware, Inc. in the United States and/or other countries.