DatabaseStatusSyntax FamilyMin Version
PostgreSQL full uuid 8.3
MySQL workaround - -
MariaDB full uuid 10.7
Oracle workaround raw -
SQL Server full uniqueidentifier -
SQLite workaround - -
Redshift workaround - -
DB2 workaround - -
Snowflake full uuid -
BigQuery workaround - -

Compare Databases

Database Details

PostgreSQL full
CREATE TABLE users (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name TEXT NOT NULL
);

INSERT INTO users (name) VALUES ('Alice')
RETURNING id;
  • Native UUID type stores values as 128-bit quantities.
  • gen_random_uuid() is built-in as of PostgreSQL 13; earlier versions require the uuid-ossp or pgcrypto extension.
  • Supports indexing, comparison operators, and casting to/from TEXT.
Docs: UUID Type
MySQL workaround
CREATE TABLE users (
  id CHAR(36) PRIMARY KEY DEFAULT (UUID()),
  name VARCHAR(255) NOT NULL
);

INSERT INTO users (name) VALUES ('Alice');
  • No native UUID type. UUIDs are typically stored as CHAR(36) or BINARY(16).
  • The UUID() function generates UUIDs but returns a string.
  • UUID_TO_BIN() and BIN_TO_UUID() functions are available in MySQL 8.0+ for efficient binary storage.
  • BINARY(16) storage is more space-efficient but requires conversion functions.
Docs: UUID()
MariaDB full
-- Native UUID column type (MariaDB 10.7+)
CREATE TABLE users (
  id UUID PRIMARY KEY DEFAULT (UUID()),
  name VARCHAR(255) NOT NULL
);

INSERT INTO users (name) VALUES ('Alice');
  • Native UUID data type added in MariaDB 10.7 - stores as a 16-byte binary value but displays as standard UUID string.
  • UUID() function generates RFC 4122 v1 UUIDs.
  • Prior to 10.7, UUIDs were stored as CHAR(36) or BINARY(16) with UUID_TO_BIN() / BIN_TO_UUID() helpers.
  • UUID_TO_BIN(uuid, 1) reorders bytes to put the time-high section first for better index locality.
Oracle workaround
CREATE TABLE users (
  id RAW(16) DEFAULT SYS_GUID() PRIMARY KEY,
  name VARCHAR2(255) NOT NULL
);

INSERT INTO users (name) VALUES ('Alice');
  • No dedicated UUID type. UUIDs are stored as RAW(16).
  • SYS_GUID() generates a 16-byte globally unique identifier.
  • SYS_GUID() output is not formatted as a standard UUID string; manual conversion is needed for display.
Docs: SYS_GUID
SQL Server full
CREATE TABLE users (
  id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWID(),
  name NVARCHAR(255) NOT NULL
);

INSERT INTO users (name) VALUES ('Alice');
  • Native UNIQUEIDENTIFIER type stores 16-byte GUIDs.
  • NEWID() generates a random UUID; NEWSEQUENTIALID() generates sequential UUIDs for better index performance.
  • NEWSEQUENTIALID() can only be used as a DEFAULT constraint.
SQLite workaround
CREATE TABLE users (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL
);

-- UUID generation is typically done in application code
INSERT INTO users (id, name)
VALUES ('550e8400-e29b-41d4-a716-446655440000', 'Alice');
  • No native UUID type or generation function.
  • UUIDs are typically stored as TEXT (36 bytes) or BLOB (16 bytes).
  • UUID generation must be handled by the application or a custom function.
Redshift workaround
CREATE TABLE users (
  id CHAR(36) PRIMARY KEY,
  name VARCHAR(255) NOT NULL
);
  • No native UUID type or UUID generation function.
  • Store as CHAR(36) or VARCHAR(36).
  • No built-in UUID generator. Use application code or a Python UDF to generate UUIDs.
  • REGEXP_REPLACE can validate UUID format.
DB2 workaround
-- Use VARCHAR(36) for RFC 4122 UUID storage
CREATE TABLE users (
  id VARCHAR(36) PRIMARY KEY,
  name VARCHAR(255) NOT NULL
);

-- GENERATE_UNIQUE() returns a unique CHAR(13) value, not a standard UUID
SELECT GENERATE_UNIQUE() FROM sysibm.sysdummy1;
  • No native UUID type.
  • GENERATE_UNIQUE() returns a unique CHAR(13) value, not a standard UUID.
  • GENERATE_UNIQUE() values are guaranteed unique but not UUID format.
  • For standard UUIDs, use application code or Java stored procedure.
Snowflake full
CREATE TABLE users (
  id UUID DEFAULT UUID_STRING(),
  name VARCHAR NOT NULL
);

SELECT UUID_STRING();
  • Snowflake documents a native UUID data type.
  • UUID_STRING() generates UUID-formatted values for insertion into UUID columns.
  • Drivers typically surface UUID values as text strings.
  • The UUID type itself does not guarantee uniqueness; enforce uniqueness with keys or constraints as needed.
BigQuery workaround
SELECT GENERATE_UUID();

CREATE TABLE users (
  id STRING DEFAULT (GENERATE_UUID()),
  name STRING NOT NULL
);
  • GENERATE_UUID() generates RFC 4122 UUIDs.
  • No dedicated UUID type - use STRING.
  • GENERATE_UUID() returns a UUID v4 string.
  • Commonly used as: id STRING DEFAULT (GENERATE_UUID()).