user5507535
user5507535

Reputation: 1800

Does Oracle 19 database support UUID columns?

Does Oracle 19 database support UUID columns, to store for example 123e4567-e89b-12d3-a456-426614174000?

I know that Oracle NoSQL supports this, but I'm looking for Oracle SQL.

If not how should I implement it? A 36 character varchar2 column with constraint to check for the value?

Upvotes: 1

Views: 4127

Answers (1)

Del
Del

Reputation: 1599

As the comments mention, while UUID isn't a supported type, you can easily implement a UUID column like this:

CREATE TABLE example
(
  uuid CHAR(36) CHECK (REGEXP_LIKE(uuid, '^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$'))
);

Here is a DBFiddle showing the check constraint in action (LINK)

Upvotes: 3

Related Questions