Questions tagged [uuid]

A Universally Unique Identifier (UUID), GUID in Microsoft parlance.

79 questions
106
votes
2 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
  • 8,776
  • 14
  • 46
  • 78
42
votes
3 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
  • 761
  • 1
  • 5
  • 15
23
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
  • 447
  • 1
  • 3
  • 9
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
  • 6
19
votes
2 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,492
  • 6
  • 21
  • 24
18
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
18
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,463
  • 1
  • 15
  • 27
14
votes
3 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
  • 8,776
  • 14
  • 46
  • 78
13
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
  • 243
  • 2
  • 5
10
votes
1 answer

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
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
  • 565
  • 7
  • 15
  • 26
8
votes
2 answers

How Uniqueidentifier in SQL Server is always a unique value globally?

As per microsoft documentation on UniqueIdentifier, This value is always a unique globally beacuse it's based on network clock and CPU clock time and on the other hand the same documentation says uniqueidentifier columns may contain multiple…
7
votes
1 answer

UUID or BIGSERIAL Foreign Keys Postgres

I have 8 tables which use UUID Primary Keys and 7 of them have UUID Foreign Keys. Would it be better for performance to use BIGSERIAL instead of UUID?
civ15
  • 173
  • 1
  • 3
7
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
  • 241
  • 1
  • 2
  • 4
7
votes
1 answer

Is it Ok to use GUID as the Foreign Key?

Here's my current situation: We have a table storing data submitted from the website form, say "MyTable". The table uses bigint (auto-increment) as the primary key. Everything is good so far. Now, that table is required to be able to store the…
zeroflaw
  • 315
  • 1
  • 6
  • 13
1
2 3 4 5 6