[ACCEPTED]-What does keyword CONSTRAINT do in this CREATE TABLE statement-sql
Country_key is simply giving a name to the 5 constraint. If you do not do this the name 4 will be generated for you. This is useful 3 when there are several constraints on the 2 table and you need to drop one of them.
As 1 an example for dropping the constraint:
ALTER TABLE PopByCountry DROP CONSTRAINT Country_Key
If you omit CONSTRAINT Contry_Key from the 6 statement, SQL server will generate a name 5 for your PRIMARY KEY constraint for you 4 (the PRIMARY KEY is a type of constraint).
By 3 specifically putting CONSTRAINT in the 2 query you are essentially specifying a name 1 for your primary key constraint.
More Related questions