D427 OA Example Questions and
answers
Add/remove Primary key to table - answer ALTER
TABLE table_name
ADD PRIMARY KEY (column_name)
remove a primary key from a table - answer ALTER
TABLE table_name
DROP PRIMARY KEY;
Add Foreign Key - answer ALTER TABLE Orders
ADD FOREIGN KEY (PersonID) REFERENCES
Persons(PersonID);
Remove Foreign Key - answer ALTER TABLE Orders
DROP FOREIGN KEY FK_PersonOrder;
add a view - answer CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
answers
Add/remove Primary key to table - answer ALTER
TABLE table_name
ADD PRIMARY KEY (column_name)
remove a primary key from a table - answer ALTER
TABLE table_name
DROP PRIMARY KEY;
Add Foreign Key - answer ALTER TABLE Orders
ADD FOREIGN KEY (PersonID) REFERENCES
Persons(PersonID);
Remove Foreign Key - answer ALTER TABLE Orders
DROP FOREIGN KEY FK_PersonOrder;
add a view - answer CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;