Esta página ainda não está disponível no idioma selecionado. Estamos trabalhando para adicionar mais opções de idiomas. Agradecemos sua compreensão.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

UUID Functions

Updated on 2024-09-03 GMT+08:00

UUID functions are used to generate UUID data (see UUID Type).

uuid_generate_v1()

Description: Generates a UUID sequence number.

Return type: UUID

Example:

1
2
3
4
5
SELECT uuid_generate_v1();
           uuid_generate_v1           
--------------------------------------
 c71ceaca-a175-11e9-a920-797ff7000001
(1 row)
NOTE:

The uuid_generate_v1 function generates a UUID based on the time information, cluster node ID, and ID of the thread that generates the sequence. The UUID is globally unique in a single cluster, however, there is a possibility that the time information, cluster node IDs, thread IDs, and clock sequences of multiple clusters are the same at the same time. Therefore, there is a low probability that UUIDs generated among multiple clusters are duplicate.

sys_guid()

Description: Generates an Oracle GUID, which is similar to the UUID. This function is compatible with Oracle.

Return type: text

Example:

1
2
3
4
5
SELECT sys_guid();
             sys_guid             
----------------------------------
 4EBD3C74A17A11E9A1BF797FF7000001
(1 row)
NOTE:

The data generation principle of the sys_guid function is the same as that of the uuid_generate_v1 function.

UUID Function Application Example

A UUID is globally unique. It can be used as a primary key or a distribution column in a data table. When uuid_generate_v1() is used as the default value of the distribution column in a data table, data can be evenly distributed to each DN through hash distribution to prevent data skew.

NOTE:

The obvious advantage of UUID is that it is globally unique and does not require a central node. UUIDs are generated independently on a single node. However, UUIDs occupy more storage space than INTs, the index efficiency is low, and the generated IDs are random, making them difficult to identify. Therefore, you need to select UUID or Sequence as the primary key of the data table based on the site requirements.

An example is as follows:

  1. The INT type is used as the distribution column.
    An example hash table mytable01 is created, and the ints are used as the distribution column. After data is inserted, data skew occurs.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    CREATE TABLE mytable01(a INT, b INT) DISTRIBUTE BY hash(a);
    CREATE TABLE
    INSERT INTO mytable01 VALUES(1, 10);
    INSERT 0 1
    INSERT INTO mytable01 VALUES(1, 10);
    INSERT 0 1
    INSERT INTO mytable01 VALUES(1, 10);
    INSERT 0 1
    INSERT INTO mytable01 VALUES(1, 10);
    INSERT 0 1
    INSERT INTO mytable01 VALUES(1, 10);
    INSERT 0 1
    SELECT * FROM mytable01;
     a | b
    ---+----
     1 | 10
     1 | 10
     1 | 10
     1 | 10
     1 | 10
    (5 rows)
    
    SELECT table_skewness('mytable01');
               table_skewness
    -------------------------------------
     ("dn_6003_6004        ",5,100.000%)
     ("dn_6001_6002        ",0,0.000%)
     ("dn_6005_6006        ",0,0.000%)
    (3 rows)
    
  2. The UUIDs are used as the distribution column.

    Create an example hash table mytable02 and use the UUIDs as the distribution column. After data is inserted, data distribution is normal.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    CREATE TABLE mytable02 (id UUID default uuid_generate_v1(), a INT, b INT) DISTRIBUTE BY hash(id);
    CREATE TABLE
    
    INSERT INTO mytable02(a, b) VALUES(1, 10);
    INSERT 0 1
    INSERT INTO mytable02(a, b) VALUES(1, 10);
    INSERT 0 1
    INSERT INTO mytable02(a, b) VALUES(1, 10);
    INSERT 0 1
    INSERT INTO mytable02(a, b) VALUES(1, 10);
    INSERT 0 1
    INSERT INTO mytable02(a, b) VALUES(1, 10);
    INSERT 0 1
    
    SELECT * FROM mytable02;
                      id                  | a | b
    --------------------------------------+---+----
     63e45c14-cc74-0e00-e9aa-0a2c3fa0fffe | 1 | 10
     63e45c1f-4d18-0700-e9ab-0a2c3fa0fffe | 1 | 10
     63e45c26-f859-0b00-e9ad-0a2c3fa0fffe | 1 | 10
     63e45c23-9e5d-0300-e9ac-0a2c3fa0fffe | 1 | 10
     63e45c2a-5825-0600-e9ae-0a2c3fa0fffe | 1 | 10
    (5 rows)
    
    SELECT table_skewness('mytable02');
               table_skewness
    ------------------------------------
     ("dn_6001_6002        ",3,60.000%)
     ("dn_6003_6004        ",2,40.000%)
     ("dn_6005_6006        ",0,0.000%)
    (3 rows)
    

Usamos cookies para aprimorar nosso site e sua experiência. Ao continuar a navegar em nosso site, você aceita nossa política de cookies. Saiba mais

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback