wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

SQL and Database Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which command is used to rollback the last transaction?

a)

COMMIT;

b)

ROLLBACK;

c)

SAVEPOINT;

d)

UNDO;

2.

How to add a primary key constraint to an existing table?

a)

ALTER TABLE Employee ADD PRIMARY KEY (EMPNO);

b)

ALTER Employee ADD PRIMARY KEY (EMPNO);

c)

ADD PRIMARY KEY TO Employee (EMPNO);

d)

ALTER Employee TABLE ADD PRIMARY KEY (EMPNO);

3.

How to add a NOT NULL constraint to a column?

a)

ALTER TABLE Employee ADD CONSTRAINT NOT NULL (EMPNO);

b)

ALTER TABLE Employee MODIFY EMPNO NOT NULL;

c)

ALTER TABLE Employee ADD NOT NULL (EMPNO);

d)

ALTER Employee MODIFY COLUMN EMPNO NOT NULL;

4.

Which command is used to insert a new record into a table?

a)

INSERT INTO Employee VALUES (101, 'John', 'Manager', 1001, 5000, NULL);

b)

ADD INTO Employee VALUES (101, 'John', 'Manager', 1001, 5000, NULL);

c)

INSERT INTO Employee SET (101, 'John', 'Manager', 1001, 5000, NULL);

d)

INSERT INTO Employee SET VALUES (101, 'John', 'Manager', 1001, 5000, NULL);

5.

How to add a new column to an existing table?

a)

ALTER TABLE Employee ADD COLUMN commission DECIMAL(10,2);

b)

ALTER Employee ADD COLUMN commission DECIMAL(10,2);

c)

ALTER TABLE Employee MODIFY commission DECIMAL(10,2);

d)

ALTER Employee TABLE ADD COLUMN commission DECIMAL(10,2);

6.

How to update the details of a column in a table?

a)

UPDATE Employee SET JOB = 'Developer' WHERE EMPNO = 101;

b)

MODIFY Employee SET JOB = 'Developer' WHERE EMPNO = 101;

c)

CHANGE Employee SET JOB = 'Developer' WHERE EMPNO = 101;

d)

ALTER Employee SET JOB = 'Developer' WHERE EMPNO = 101;

7.

How to rename a column in a table?

a)

ALTER TABLE Employee RENAME COLUMN commission TO bonus;

b)

CHANGE Employee RENAME COLUMN commission TO bonus;

c)

MODIFY Employee RENAME COLUMN commission TO bonus;

d)

RENAME Employee RENAME COLUMN commission TO bonus;

8.

Which command is used to delete a record from a table?

a)

DELETE FROM Employee WHERE EMPNO = 105;

b)

REMOVE FROM Employee WHERE EMPNO = 105;

c)

DROP FROM Employee WHERE EMPNO = 105;

d)

ERASE FROM Employee WHERE EMPNO = 105;

9.

How to count the number of employee names in a table?

a)

SELECT COUNT(E_name) FROM Employee;

b)

SELECT TOTAL(E_name) FROM Employee;

c)

SELECT SUM(E_name) FROM Employee;

d)

SELECT NUMBER(E_name) FROM Employee;

10.

How to find the maximum age in a table?

a)

SELECT MAX(Age) FROM Employee;

b)

SELECT HIGHEST(Age) FROM Employee;

c)

SELECT BIGGEST(Age) FROM Employee;

d)

SELECT LARGEST(Age) FROM Employee;

11.

How to sort salaries of employees in ascending order?

a)

SELECT Salary FROM Employee ORDER BY Salary ASC;

b)

SELECT Salary FROM Employee ORDER BY Salary;

c)

SELECT Salary FROM Employee SORT BY Salary;

d)

SELECT Salary FROM Employee ORDER Salary ASC;

12.

How to group salaries of employees?

a)

SELECT Salary FROM Employee GROUP BY Salary;

b)

SELECT Salary FROM Employee ORDER BY Salary;

c)

SELECT Salary FROM Employee SORT BY Salary;

d)

SELECT Salary FROM Employee GROUP Salary;

13.

How to open a cursor in PL/SQL?

a)

OPEN cursor_name;

b)

ACTIVATE cursor_name;

c)

BEGIN cursor_name;

d)

START cursor_name;

14.

How to close a cursor in PL/SQL?

a)

CLOSE cursor_name;

b)

DEACTIVATE cursor_name;

c)

END cursor_name;

d)

STOP cursor_name;

15.

What does CRUD stand for in database operations?

a)

Create, Read, Update, Delete

b)

Create, Retrieve, Update, Delete

c)

Create, Remove, Update, Delete

d)

Create, Reorganize, Update, Delete