A Universally Unique Identifier (UUID), GUID in Microsoft parlance.
Questions tagged [uuid]
89 questions
140
votes
3 answers
Default value for UUID column in Postgres
In Postgres 9.x, for a column of type UUID, how do I specify a UUID to be generated automatically as a default value for any row insert?
Basil Bourque
- 11,188
- 20
- 63
- 96
67
votes
6 answers
How should I index a UUID in Postgres?
I'm new to PostgreSQL and somewhat new to databases in general. Is there an established way of how we should index UUID values in Postgres? I'm split between using hashing and using a trie, unless there's already something built-in that it uses…
sudo
- 1,061
- 1
- 10
- 18
30
votes
1 answer
PostgreSQL two different ways to generate a UUID: gen_random_uuid vs uuid_generate_v4?
What is the difference between the following two functions
gen_random_uuid() provided by pgcrypto extension
uuid_generate_v4() provided by uuid-ossp extension
Are they both the same behind the scenes? Any performance impacts on using one?
user148246
26
votes
2 answers
What is the purpose of a Row_GUID column?
I've been digging around in the AdventureWorks2012 database and see Row_GUID used in several tables.
There are 2 parts to my question:
When should I include a Row_GUID column?
What are the uses and benefits of a Row_GUID column?
SQLSuperHero
- 477
- 1
- 4
- 10
22
votes
3 answers
Is there a penalty for using BINARY(16) instead of UNIQUEIDENTIFIER?
I've recently inherited a SQL Server database that uses BINARY(16) instead of UNIQUEIDENTIFIER to store Guids. It does this for everything including primary keys.
Should I be concerned?
Jonathan Allen
- 3,612
- 7
- 25
- 25
19
votes
2 answers
Should I call my UUID primary key column ID or not?
I'm working on a database design that extensively uses UUIDs for PRIMARY KEYs. However, this confronts me with a very consequential choice. How do I name these columns? I would call them uuid, except that, UUID being an identifier, I then have to…
BigSmoke
- 784
- 1
- 7
- 13
19
votes
4 answers
Casting an array of texts to an array of UUIDs
How can I cast an array of texts into an array of UUIDs?
I need to do a join between two tables: users and projects.
The users table has an array field named project_ids containing the project IDs as text.
The projects table had a UUID field named…
Sig
- 455
- 1
- 5
- 14
19
votes
4 answers
Does Postgres offer a feature like “NEWSEQUENTIALID” in MS SQL Server to make UUID as primary key more efficient
Microsoft SQL Server offers the NEWID command to generate a new GUID (the Microsoft version of UUID) value that can be used as a primary key value (in their uniqueidentifier data type). These are not sequential in nature, so updating an index can be…
Basil Bourque
- 11,188
- 20
- 63
- 96
19
votes
1 answer
psql 9.5: gen_random_uuid() not working
SELECT gen_random_uuid()
produces output
ERROR: function gen_random_uuid() does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
I ran CREATE EXTENSION pgcrypto; on…
d9k
- 293
- 1
- 2
- 8
19
votes
2 answers
SQL Server UniqueIdentifier / GUID internal representation
A colleague of mine sent me an interesting question, that I can't entirely explain.
He ran some code (included below) and got somewhat unexpected results from it.
Essentially, when converting a UniqueIdentifier (which I'll refer to as Guid from here…
Der Kommissar
- 1,523
- 1
- 16
- 27
18
votes
2 answers
How do I install/enable the uuid-ossp extension on Postgres 9.3?
I’m using Postgres 9.3 on Ubuntu Linux 14.04. How do I install/enable the uuid-ossp extension? I first verified the contrib package was installed …
root@prodbox:/home/rails/myproject# apt-get install postgresql-contrib
Reading package lists...…
Dave
- 753
- 10
- 22
- 39
17
votes
4 answers
What can go wrong using the same sequence across multiple tables in postgres?
We are considering using a shared sequence to assign ids to primary keys for all of the tables in our database. There are about 100 of them. Only a couple are inserted to frequently and regularly. We want to rule out it being "a terrible idea for an…
Burleigh Bear
- 283
- 2
- 5
13
votes
1 answer
In Postgres, how to select by a column of type UUID
I have a DB table that someone else created, its PK is a single column of type 'uuid'. I'm struggling to perform a simple select by that column. Examples I have tried with no success:
select from site where id =…
Clint Eastwood
- 361
- 1
- 2
- 6
10
votes
2 answers
PostgreSQL custom operator UUID to varchar
I have a rather complicated Postgres database in which many UUID fields were incorrect stored as VARCHAR. I'd like to migrate them over in piecemeal, but unfortunately, doing so breaks all my views as Postgres doesn't have a built in operator for…
keithhackbarth
- 225
- 1
- 2
- 7
9
votes
3 answers
Why is there no max(uuid)/min(uuid) function?
Why can I use a UUID to sort rows:
SELECT uuid_nil()
ORDER BY 1;
But I cannot compute the maximum value:
SELECT max(uuid_nil());
[42883] ERROR: function max(uuid) does not exist
Hint: No function matches the given name and argument types. You…
xehpuk
- 327
- 2
- 5
- 11