Reputation: 141340
Which one of the following ways would you use in declaring Primary Keys by Postgres?
CREATE TABLE user(
user_id PRIMARY KEY,
...
)
CREATE TABLE user(
user_id NOT NULL,
...
CONSTRAINT user_pk PRIMARY KEY(user_id);
)
Upvotes: 0
Views: 465
Reputation: 994231
I would use method #1.
One reason to use method #2 is if your primary key were to span more than one column. In that case, method #1 won't work because it only supports a single column primary key.
Upvotes: 1