CARVIEW |
Select Language
HTTP/2 200
date: Wed, 23 Jul 2025 20:38:35 GMT
content-type: text/html; charset=utf-8
cf-ray: 963dfb754aa0d3d4-BLR
cf-cache-status: DYNAMIC
cache-control: private
set-cookie: prov=695f85d1-c33f-4e65-857a-a407e559b2aa; expires=Thu, 23 Jul 2026 20:38:35 GMT; domain=.stackexchange.com; path=/; secure; httponly
strict-transport-security: max-age=31536000; includeSubDomains
vary: Accept-Encoding
content-security-policy: upgrade-insecure-requests; frame-ancestors 'self' https://stackexchange.com
x-clacks-overhead: GNU Terry Pratchett
x-frame-options: SAMEORIGIN
x-request-guid: d79e7f5e-8291-41e6-9be7-8834c694040b
x-worker-origin-response-time: 531000000
x-dns-prefetch-control: off
set-cookie: prov=695f85d1-c33f-4e65-857a-a407e559b2aa; Path=/; HttpOnly; Domain=stackexchange.com
set-cookie: __cf_bm=fgG0YinALFSRVTuikxVmiNpOaCsjQpMX..IlTPNdiy4-1753303115-1.0.1.1-cZ2Qm2ERdJsSM7uLAicu6WDqGAbB.VpWXtCiaaWzXES42WnCx6QOcFKHLJ10hJhbo4Xrm5lXzlzYSD2JqUboz5sulAz7gWa1NS._uxTKA.I; path=/; expires=Wed, 23-Jul-25 21:08:35 GMT; domain=.stackexchange.com; HttpOnly; Secure; SameSite=None
set-cookie: _cfuvid=l6_MCQgZ4wJf4UkzmygkX4sZEkelryhnRvGhFamg6TQ-1753303115630-0.0.1.1-604800000; path=/; domain=.stackexchange.com; HttpOnly; Secure; SameSite=None
server: cloudflare
content-encoding: gzip
Newest 'primary-key' Questions - Database Administrators Stack Exchange
Skip to main content
Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack ExchangeTeams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about TeamsQuestions tagged [primary-key]
In relational database design, a primary key can uniquely identify each row in a table. A primary key comprises a single column or a set of columns.
652 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
2
votes
1
answer
271
views
Change Tracking and Primary keys
I have a SQL Server database with Change Tracking enabled on a hand full of tables and it's used by another application on the cloud to sync data between both databases.
When an existing customer ...
1
vote
1
answer
66
views
For two oracle tables is it possible to keep their primary keys in separate integer ranges?
For two Oracle database tables in the same schema,
is it possible to keep their primary keys totally separate, so that an integer representing a primary key would appear in at most one of these tables?...
1
vote
0
answers
47
views
Foreign key does not appear in table structure in PHPMYADMIN
I am creating two tables called customer and item.
For the customer table customerID is the primary key and for the item table itemID is the primary key. And I am creating another table which is ...
0
votes
0
answers
51
views
Why does Postgresql use a Seq Scan on the first column of the PK?
This is my table:
CREATE TABLE IF NOT EXISTS public.ob_samples_sc5555 (
stamp timestamp(6) with time zone NOT NULL,
oblvl smallint NOT NULL,
olots integer NOT NULL,
CONSTRAINT ...
0
votes
1
answer
52
views
I should let the user type the primary key?
I have a Products table, 2 options:
Let the user type the PK because some users can input Barcodes or no (in this case, the app will let to user free to input anything for example his own code ...
4
votes
1
answer
252
views
Foreign Key join elimination working in one query but not in the other one?
In AdventureWorks2016 when I execute the following query:
USE AdventureWorks2016
BEGIN TRAN;
SELECT
Sales.SalesOrderHeader.SalesOrderID
FROM
Sales.SalesOrderHeader
JOIN
Sales.Customer
...
0
votes
1
answer
34
views
How to design properly a membership history accross multiple groups?
I'm looking to design an application (Python with sqlite) which deals with some contributors moving across several groups through time.
My design looks currently like (PK in bold weight, FK in italic, ...
0
votes
1
answer
87
views
Primary key constraint
I have few questions related to primary key in a table
I have a table with id as identity column and it is set as primary key
and also it created as clustured index by default
I want to remove the ...
user306367
0
votes
5
answers
159
views
Log table without primary key
I have a SQL Server log table that includes a column "Id"
This is an identity column, but not a primary key, it is not even indexed.
This would have just been set up from some tutorial for ...
3
votes
2
answers
535
views
Is there any benefit to declaring an index that contains a primary key as unique?
Suppose that I have a table with many columns that I don't care about, but two that I do: Primary and Secondary. There is a clustered primary key on Primary.
CREATE TABLE [dbo].[...
0
votes
0
answers
82
views
Is it a good idea to use time as primary key component?
I have a log/audit table which the only index I will ever use is time window.
Is it a good idea to PRIMARY KEY it as:
CREATE TABLE events (
created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW(...
1
vote
1
answer
317
views
How to attach partition with primary key
I'm struggling to attach a partition to a table with a primary key.
I have a partitioned table Transactions:
create table "Transactions"
(
id bigserial ...
3
votes
2
answers
315
views
Why does MySQL generate a `key` statement in DDL for composite primary keys?
I am using MySQL version 8.3.0.
I can create a “many to many” relationship between persons and teams tables with the following SQL statements:
create table persons (
id bigint not null,
last_name ...
0
votes
1
answer
37
views
Create composed key (YEAR+COUNT) field with trigger after insert in SQLITE
I have a table Product with two columns: name of product and price
CREATE TABLE IF NOT EXISTS YearCounters (
year INTEGER PRIMARY KEY,
counter INTEGER DEFAULT 0
);
-- Product Table
CREATE ...
-2
votes
1
answer
2k
views
How to remove violation of duplicate primary key in the table in sql server? [closed]
I am encountering a customer error as they are unable to print due to violation of primary key as being duplicate, below its where i went and check for the db column in the table and saw this as the ...
- The Overflow Blog
-
-
- Featured on Meta
-
-
Related Tags
mysql × 166
sql-server × 159
database-design × 155
foreign-key × 126
postgresql × 106
index × 80
unique-constraint × 38
performance × 37
auto-increment × 33
clustered-index × 30
innodb × 27
constraint × 25
relational-theory × 21
oracle × 18
schema × 18
identity × 17
normalization × 16
mariadb × 14
sql-server-2008 × 14
surrogate-key × 14
duplication × 13
uniqueidentifier × 13
query-performance × 11
sequence × 11
more related tags
Hot Network Questions
- Business technical issues lead to unsuccessful payment being considered successful. Do I have any duty to notify?
- Finding the value of collector resistor
- bootstrapping for variance estimation takes too long
- Manga/manhwa where protagonist is the only one summoned to a different other world
- How to Select and Isolate Only the Fillet Parts of a Curve in Geometry Nodes?
- Why is this endgame winning for Black?
- What fiction genres do literary agents recognize?
- How to expand an algebraic function like √R(x) into a continued fraction in Mathematica?
- What does this "lightbulb-ish" symbol mean in figure 1 of the Diffie Hellmann paper?
- OId Movie about an alien city that plays a repeating melody
- Render / Convert .midi / .mid to FLAC on Linux
- Huge Difference in Interaction P-values Between Linear vs. Ordinal Regression (0.991 vs. 0.001)
- What was the Russia-Germany 1996 "Defence pact" that Russia recently announced has been terminated?
- Is the appearance of certain kinds of clouds at altitude of > 30000 feet a recent phenomenon?
- SOSL/SOQL isn't returning User records
- Is it legal for businesses to give financial incentives for leaving positive reviews on review sites (e.g., Google Maps, Yelp, Facebook, Amazon)?
- Story about a room on Mars that contains God
- Did Germany declare the Donetsk People’s Republic to be a terrorist organization, at some point?
- In QGIS installed via OSGeo4W on Windows 11, what is the path to the command history file for the Python console?
- A soviet sci-fi novel (novelette?) with frogs?
- Did Webster's Dictionary define Fascism by its relationship to corporations until 1987?
- Why does internal energy end up higher in an irreversible adiabatic process, even though the work done is less?
- At Helsinki airport, connecting from Schengen to non-Schengen flight, is there exit immigration?
- Why is `&self` allowed in the parameters of `&mut self` methods, but not `&mut self`?