SQL ALTER TABLE – Quiz

For each question below, select the best answer. To select the best answer, click on the circle located on the left of this answer. When all questions are answered, click on the Submit button.

Question 1

The column revenue in table sales is of type integer. This column does not accept null values. You want it to be of type decimal(5,0). You still do not want it to accept null values. What is the correct syntax:

ALTER TABLE sales CHANGE revenue revenue int NOT NULL
ALTER TABLE sales CHANGE revenue revenue decimal(5,0) NOT NULL
ALTER TABLE sales CHANGE revenue integer decimal(5,0) NOT NULL
ALTER TABLE sales CHANGE integer revenue decimal(5,0)

Question 2

You want to add the new column month on the left hand side of column day and on the right hand side of column year. Which fragment is correct:

ADD integer not null after month
ADD integer not null after day
ADD integer not null after year

Question 3

What is the right syntax to add column month in table revenue:

ALTER TABLE month ADD revenue int
ALTER TABLE revenue ADD month int
ALTER TABLE revenue, ADD month int

Question 4

What is the right syntax to remove column month in table revenue:

ALTER TABLE revenue DROP month
ALTER TABLE revenue DELETE month
ALTER TABLE revenue REMOVE month
ALTER TABLE month REMOVE revenue

Question 5

What is the right syntax to change the name of the table clients to “prospects”:

ALTER TABLE clients prospects
ALTER TABLE prospects clients
ALTER TABLE clients RENAME TO prospects
ALTER TABLE clients CHANGE TO prospects
ALTER TABLE prospects CHANGE TO clients

 

 

Once you have completed the quiz, calculated your score and reviewed your answers, I invite you to go to the next lesson: Database Administration using SQL.
 
Share on:


Author:
Last udpated: September 10, 2017
Created: September 20, 2014