Category: Server Keys
-
Drop a Foreign Key
ALTER TABLE statement is used to drop a foreign key from a table once it has been created. Syntax: Parameter explanation table_name: It specifies the name of the table where the foreign key has been created. fk_name: It specifies the name of the foreign key that you want to remove. Example: In the previous example we have…
-
SQL Server Foreign Key
In SQL Server, foreign key is used to enforce referential integrity within your SQL Server database. It specifies that a value in one table must also appear in another table. The referenced table is called parent table while the table having foreign key is called child table. The foreign key in the child table will…
-
Drop Primary Key
ALTER TABLE statement is used to drop a primary key in SQL Server. Syntax: Example: Let’s drop a primary key using the ALTER TABLE statement in SQL Server. Here we take “cricketers2” table which has “cricketer_id” as a primary key and “cricketers2_pk” as constraint name. Output:
-
Disable Primary key
ALTER INDEX statement is used to disable a primary key in SQL Server database. Syntax: Example: Disable the primary key “customer_id” on the table “customers” Output:
-
Enable Primary Key
ALTER INDEX statement is used to enable a primary key in SQL Server database. Syntax: Example: Enable the primary key “customer_id” on the table “customers”. Output: Now primary key “customer_id” is enabled in table “customers”.
-
SQL Server Primary Key
SQL Server Primary key is a single field or combination of fields that is used to uniquely define a record. Any field of a primary key cannot contain a null value. A table can have only one primary key. You can define a primary key either in a CREATE TABLE statement or an ALTER TABLE…