Last active
August 19, 2016 21:22
-
-
Save andrewfinnell/c92d08136b1f7ce7a892cb297a510d05 to your computer and use it in GitHub Desktop.
Postgres Table with UUID Primary key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Turn on the pgcrypto extension which should be installed | |
| -- by default in recent Postgres builds. | |
| CREATE EXTENSION pgcrypto; | |
| -- Create a table with the primary key as an UUID | |
| -- using the gen_random_uuid() function which is | |
| -- available through the pgcrypto extension. | |
| CREATE TABLE tbl_sometable | |
| ( | |
| id uuid NOT NULL DEFAULT gen_random_uuid(), | |
| name text, | |
| tags text, | |
| CONSTRAINT tbl_sometable_pkey PRIMARY KEY (id) | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment