In data definition language (DDL), which of the following statements can be used to add a primary key to a table?CREATE TABLE Artists ADD 'artist_pk' AS PRIMARY KEY (artistID)ADD CONSTRAINT 'artist_pk' PRIMARY KEY (artistID) ALTER TABLE Artists PRIMARY KEY (artistID)ALTER TABLE Artists ADD PRIMARY KEY (artist_pk);
Question
In data definition language (DDL), which of the following statements can be used to add a primary key to a table?CREATE TABLE Artists ADD 'artist_pk' AS PRIMARY KEY (artistID)ADD CONSTRAINT 'artist_pk' PRIMARY KEY (artistID) ALTER TABLE Artists PRIMARY KEY (artistID)ALTER TABLE Artists ADD PRIMARY KEY (artist_pk);
Solution
The correct statement to add a primary key to a table in Data Definition Language (DDL) is:
ALTER TABLE Artists ADD CONSTRAINT 'artist_pk' PRIMARY KEY (artistID);
This statement is used to add a primary key to an existing table. The ALTER TABLE statement is used to add, delete/drop or modify columns in an existing table. The ADD CONSTRAINT command is used to create a new constraint for an existing table. 'artist_pk' is the name of the primary key and artistID is the column on which the primary key is based.
Similar Questions
Which of the following statements can be used to add a new primary key to an existing table that has no primary key? *1 pointADD PRIMARY KEY TO TABLE table_name(column_name)ALTER TABLE table_name ADD CONSTRAINT PRIMARY KEY(column_name)ALTER TABLE table_name ADD PRIMARY KEY(column_name)ADD PRIMARY KEY (column_name) TO table_name
Archie is developing a library management system to manage books, authors, and borrowers. The system needs to handle three main types of data: BOOKS, AUTHORS, and BORROWERS.Write the DDL statements to create the following tables with the mentioned constraints to handle the data: symbol refers to the primary key NN refers to Not NULL After creating the tables, Archie needs to:Alter the BOOKS table to change the primary key to Title to ensure each book is uniquely identified by its title.Drop the primary key from the BORROWERS table as it is no longer requiredAlter the AUTHORS table to change the Nationality to NULL Note: The user must write only the query to create and alter the table. The query to display the description of the table is already given.Input format :No console inputOutput format :The output displays the successful table creation status and the structure of all three tablesRefer to the sample output.Sample test cases :Input 1 :Output 1 :Table BOOKS created.Table AUTHORS created.Table BORROWERS created.Table BOOKS altered.Table BOOKS altered.Table BORROWERS altered.Table AUTHORS altered. Name Null? Type __________________ ___________ ________________ BOOKID NOT NULL NUMBER TITLE NOT NULL VARCHAR2(200) AUTHORID NOT NULL NUMBER PUBLICATIONYEAR NOT NULL NUMBER Name Null? Type ______________ ___________ ________________ AUTHORID NOT NULL NUMBER NAME NOT NULL VARCHAR2(100) NATIONALITY VARCHAR2(100) Name Null? Type _________________ ___________ ________________ BORROWERID NOT NULL NUMBER NAME NOT NULL VARCHAR2(100) MEMBERSHIPDATE NOT NULL DATE TABLE_NAME COLUMN_NAME POSITION STATUS _____________ ______________ ___________ __________ BOOKS TITLE 1 ENABLED 1 row selected. Note :
Which attributes of columns in a table must always be defined in a CREATE TABLE statement?1 puntoDatatype and number of columns Datatype and Primary Key constraint Name and datatypeName and Primary Key constraint
What is the primary key used for in a relational database?Select one:a. To link tables togetherb. To perform data aggregationc. To enforce referential integrityd. To uniquely identify each record in a table
Which of the following do you need to consider when you make a table in SQL?a.Data typesb.Primary keysc.Default valuesd.All of the mentioned
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.