Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Mastering SQL DDL and DML Commands

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What SQL command is used to create a new table?

a)

INSERT TABLE

b)

MODIFY TABLE

c)

ADD TABLE

d)

CREATE TABLE

2.

How do you add a new column to an existing table?

a)

CREATE TABLE table_name ADD column_name data_type;

b)

UPDATE table_name SET column_name = value;

c)

ALTER TABLE table_name ADD COLUMN column_name data_type;

d)

INSERT INTO table_name (column_name) VALUES (value);

3.

What command would you use to remove a table from a database?

a)

DELETE TABLE table_name;

b)

CLEAR TABLE table_name;

c)

DROP TABLE table_name;

d)

REMOVE TABLE table_name;

4.

Which SQL statement is used to insert new data into a table?

a)

INSERT INTO

b)

DELETE FROM

c)

UPDATE

d)

SELECT * FROM

5.

How can you update existing records in a table?

a)

Create a new table with the updated records.

b)

Use the SQL SELECT statement to retrieve records.

c)

Delete the records using the SQL DELETE statement.

d)

Use the SQL UPDATE statement with SET and WHERE clauses.

6.

What is the SQL command to delete records from a table?

a)

DELETE FROM table_name WHERE condition;

b)

REMOVE FROM table_name WHERE condition;

c)

DELETE table_name WHERE condition;

d)

DROP table_name WHERE condition;

7.

How can you rename an existing column?

a)

ALTER TABLE table_name RENAME COLUMN column_name;

b)

ALTER COLUMN table_name RENAME column_name;

c)

sp_name 'column_name', 'new_name';

d)

sp_rename 'table_name.column_name', 'new_name', 'COLUMN';

8.

How do you change the data type of a column in a table?

a)

Change column_name data_type in the database settings;

b)

Use ALTER COLUMN column_name SET DATA TYPE new_data_type;

c)

Use ALTER TABLE table_name ALTER COLUMN column_name new_data_type;

d)

Use UPDATE table_name SET column_name = new_data_type;

9.

What command would you use to drop a column from a table?

a)

ALTER TABLE table_name DROP COLUMN column_name;

b)

REMOVE column_name FROM table_name;

c)

DROP column_name IN table_name;

d)

DELETE COLUMN column_name FROM table_name;

10.

What is the correct syntax to insert multiple records to a database table at once?

a)

INSERT INTO table_name (column1, column2) VALUES (value1a, value2a, value1b, value2b);

b)

INSERT table_name (column1, column2) VALUES (value1a, value2a), (value1b, value2b);

c)

INSERT INTO table_name (column1, column2) VALUES (value1a, value2a), (value1b, value2b), (value1c, value2c);

d)

INSERT ONTO table_name VALUES (value1a, value2a), (value1b, value2b);

11.

What SQL command is used to modify the structure of a table?

a)

ALTER TABLE

b)

SELECT * FROM

c)

DROP TABLE

d)

CREATE TABLE

12.

How do you delete all records from a table without removing the table itself?

a)

REMOVE FROM table_name;

b)

DROP TABLE table_name;

c)

DELETE FROM table_name;

d)

TRUNCATE table_name;

13.

What is the difference between DROP and TRUNCATE?

a)

There's no difference, both DROP and TRUNCATE delete all rows from a table

b)

DROP removes the entire table and its structure, while TRUNCATE deletes all rows but keeps the table structure intact.

c)

TRUNCATE removes the entire table and its structure, while DROP deletes all rows but keeps the table structure intact.

d)

There's no difference, both DROP and TRUNCATE remove the entire table

14.

How can you update specific records based on a condition?

a)

Use SQL UPDATE with a WHERE clause.

b)

Use SQL INSERT with a WHERE clause.

c)

Use SQL SELECT with a WHERE clause.

d)

Use SQL DELETE with a WHERE clause.

15.

What is the difference between DDL and DML commands in SQL?

a)

DDL commands manipulate data; DML commands define structure.

b)

DDL commands define database structure; DML commands manipulate data within that structure.

c)

DDL commands are only for deleting data; DML commands are for updating data.

d)

DDL commands are used for querying data; DML commands are for creating tables.