Questions tagged [uniqueidentifier]

66 questions
177
votes
6 answers

Guid vs INT - Which is better as a primary key?

I've being reading around reasons to use or not Guid and int. int is smaller, faster, easy to remember, keeps a chronological sequence. And as for Guid, the only advantage I found is that it is unique. In which case a Guid would be better than and…
BrunoLM
  • 3,533
  • 7
  • 28
  • 22
57
votes
7 answers

Why should I create an ID column when I can use others as key fields?

Possible Duplicate: Why use an int as a lookup table's primary key? So far, I'm accustomed to creating an ID column for every table and it is practical in a way that it makes me not think about decision making about primary key theories. The…
57
votes
3 answers

What is the optimal data type for an MD5 field?

We are designing a system that is known to be read-heavy (on the order of tens of thousands of reads per minute). There is a table names that serves as a sort of central registry. Each row has a text field representation and a unique key that is…
28
votes
3 answers

Should I use UUID as well as ID

I've been using UUIDs in my systems for a while now for a variety of reasons ranging from logging to delayed correlation. The formats I used changed as I became less naive from: VARCHAR(255) VARCHAR(36) CHAR(36) BINARY(16) It was when I reached…
Flosculus
  • 391
  • 1
  • 3
  • 6
26
votes
2 answers

What is the data type of the ‘ctid’ system column in Postgres?

The Postgres system columns are documented in Chapter 5. Data Definition > 5.4. System Columns. That page mentions that oid values “are 32-bit quantities”. And that page says the same about transaction identifiers. So I will assume that means oid,…
Basil Bourque
  • 11,188
  • 20
  • 63
  • 96
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
17
votes
3 answers

Securely generate a UNIQUEIDENTIFIER in SQL Server

I intend to be using a UNIQUEIDENTIFIER as an access key that users can use to access certain data. The key will act as a password in that sense. I need to generate multiple such identifiers as part of an INSERT...SELECT statement. For architectural…
usr
  • 7,390
  • 5
  • 33
  • 58
15
votes
5 answers

Sequential GUID or bigint for 'huge' database table PK

I know this type of question comes up a lot, but I've yet to read any compelling arguments to help me make this decision. Please bear with me! I have a huge database - it grows by about 10,000,000 records per day. The data is relational, and for…
Barguast
  • 341
  • 3
  • 6
14
votes
3 answers

Indexing a PK GUID in SQL Server 2012

My developers have setup their application to use GUID's as PK for pretty much all of their tables and by default SQL Server has setup the clustered index on these PK's. The system is relatively young and our biggest tables are just over a million…
njkroes
  • 655
  • 4
  • 7
  • 15
11
votes
8 answers

Identity Columns or UDF that explicitly generates a unique id?

I am in middle of a debate about whether it is better to make a PRIMARY KEY out of an Identity Columns, our out of a UDF that explicitly generates a unique id. I am arguing for the Identity Column. My partner is arguing for generating the values…
kacalapy
  • 2,062
  • 3
  • 27
  • 36
11
votes
3 answers

Return the uniqueidentifier generated by a default on insert

Goal Retrieve the latest guid value in real time after you have inserted the value in the table Problem Don't know how to do it Info The code should only specify new values for address and zipcode There can be lots of data in the…
KLN
  • 331
  • 1
  • 4
  • 10
10
votes
2 answers

How to use Unique key via combinations of table fields?

Take a look at the following sqlfiddle: http://sqlfiddle.com/#!2/dacb5/1 CREATE TABLE contacts ( id int auto_increment primary key, name varchar(20), network_id int, network_contact_id int ); INSERT INTO…
Jake Wilson
  • 2,487
  • 8
  • 22
  • 23
9
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…
8
votes
4 answers

Is this a standard way to design a database?

I recently learned about how relationships are defined in the database at work, and was wondering if this is a standard practice. Let's say we have two processes: Process A, and Process B. Process B depends on the results from Process A, so there…
sooprise
  • 249
  • 2
  • 3
8
votes
5 answers

How to uniquely identify SQL instance

I need to find a way how to identify SQL Instance no matter what changes were done to SQL Server and\or Windows Server where it is running, because we're collecting remotely information about instances into our operational database and still…
R1cky
  • 277
  • 1
  • 4
  • 10
1
2 3 4 5