SQL Server
SELECT NEWID();
Random v4-style GUID as a UNIQUEIDENTIFIER. NEWSEQUENTIALID() gives index-friendly values but only works as a column default.
Four named functions with different versions and shapes, plus one engine that makes you roll your own.
Filed under Types & casting
All five mint something unique but none agree on shape or version: random v4 in SQL Server and PostgreSQL (plus v7 in PostgreSQL 18), time-based v1 in MySQL, a RAW GUID in Oracle, and hand-rolled hex in SQLite. For cross-engine code, generate UUIDs in the application.
Every engine can mint a unique id, but the versions differ (v1-style time-based vs v4 random), the shapes differ (dashes, case, RAW), and SQLite alone has no function at all.
SELECT NEWID();
Random v4-style GUID as a UNIQUEIDENTIFIER. NEWSEQUENTIALID() gives index-friendly values but only works as a column default.
SELECT GEN_RANDOM_UUID();
Built in since PostgreSQL 13 (pgcrypto before that) and returns v4. PostgreSQL 18 adds uuidv7() for time-ordered ids; uuid_generate_v1() and friends come from the uuid-ossp extension.
SELECT UUID();
Version 1: timestamp plus node id, so values reveal the host and creation time. The text form starts with the low time bits and does not sort by time; UUID_TO_BIN(UUID(), 1) swaps the time fields so the binary form does.
SELECT LOWER(HEX(RANDOMBLOB(16)));
No uuid function: 32 random hex chars with no dashes and no version bits. Real UUID formatting needs an app-side value or a custom function.
SELECT RAWTOHEX(SYS_GUID()) FROM dual;
SYS_GUID() returns a 16-byte RAW that is not an RFC 4122 UUID; RAWTOHEX renders 32 uppercase hex chars with no dashes. Recent 23ai releases add UUID(), which returns a random v4 UUID as RAW(16).
SQL Server's NEWID, PostgreSQL's GEN_RANDOM_UUID and Oracle's newer UUID() are random v4, and PostgreSQL 18's uuidv7() is time-ordered. MySQL's UUID() is v1 (timestamp plus node id), which leaks the host. Oracle's SYS_GUID() follows no UUID version at all.
Not strictly: it is 16 random bytes formatted as hex, with no version/variant bits set. Uniqueness is fine at 128 bits; interop with strict UUID parsers is not.
App-side generation keeps IDs available before insert (batching, offline clients) and is identical across engines; DB-side defaults guarantee no app can forget it.
Where the UUID can be a real type, and where it is 16 bytes wearing a costume.
Five engines, five spellings of the column that numbers itself.
The most common ALTER: extend the table without losing data.
SQLly is a native SQL workbench for macOS, Windows and Linux. Its formatter and plan viewer work in all five dialects.