wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

sql commands

Total questions: 35

Worksheet time: 26mins

Name
Class
Date
1.

Which statement allows us to add a record to a table?

a)

Add To

b)

Update To

c)

Add Into

d)

Insert Into

2.

In existing table, ALTER TABLE statement is used to

a)

Add columns

b)

Add constraints

c)

Delete columns

d)

Delete constrains

e)

All the above

3.

This symbol is an SQL wildcard that can substitute for one or more characters when searching for data in a database.

a)

$

b)

%

c)

=

d)

*

4.

If you don’t specify ASC or DESC after a SQL ORDER BY clause, the following is used by default

a)

ASC

b)

DESC

c)

There is no default value

d)

None of the mentioned

5.

Find the name of those cities with temperature and condition whose condition is either sunny or cloudy but temperature must be greater than 70.

a)

SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ AND condition = ‘cloudy’ OR temperature > 70

b)

SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ OR condition = ‘cloudy’ OR temperature > 70

c)

SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ OR condition = ‘cloudy’ AND temperature > 70

d)

SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ AND condition = ‘cloudy’ AND temperature > 70

6.

With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” ends with an “a”?

a)

SELECT * FROM Persons WHERE FirstName=’a’

b)

SELECT * FROM Persons WHERE FirstName LIKE ‘a%’

c)

SELECT * FROM Persons WHERE FirstName LIKE ‘%a’

d)

SELECT * FROM Persons WHERE FirstName=’%a%’

7.

Here which of the following displays the unique values of the column?

SELECT ________ dept_name

FROM instructor;

a)

from

b)

like

c)

unique

d)

distinct

8.

Which of the following conditions has to be satisfied for INNER JOIN to work?

a)

Columns used for joining must have different names

b)

Columns used for joining must have same name

c)

Columns used for joining can be of different types

d)

Columns used for joining can have same or different name

9.

Which of the following SQL statements will retrieve only the records where there is a match between the Customers and Orders tables?

a)

SELECT * FROM Customers LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID;

b)

SELECT * FROM Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID;

c)

SELECT * FROM Customers RIGHT JOIN Orders ON Customers.CustomerID = Orders.CustomerID;

10.

Which keyword is used to filter the grouped rows in the result set based on a condition?

a)

WHERE

b)

GROUP BY

c)

DISTINCT

d)

HAVING

11.

How can the name of Student "VIRAT" changed to "ROHIT"

a)

UPDATE STUDENT SET NAME = 'ROHIT' HAVING NAME = 'VIRAT'

b)

UPDATE NAME = 'VIRAT' WHERE NAME = 'VIRAT'

c)

UPDATE TABLE STUDENT SET NAME = 'ROHIT' WHERE NAME = 'VIRAT'

d)

UPDATE STUDENT SET NAME = 'ROHIT' WHERE NAME = 'VIRAT'

12.

Select the correct foreign key constraint?

a)

Referential Integrity

b)

Entity Integrity

c)

Domain Integrity

d)

Foreign Integrity

13.

During transaction before commit which of the following statements is done automatically in case of shutdown?

a)

Rollback

b)

Commit

c)

View

d)

Flashback

14.

What is expected when you run the below statement .

TRUNCATE TABLE STUDENTS;

a)

Will delete data from Students table but not commit the changes.

b)

Will Delete all data from Students table successfully.

c)

will throw exception

d)

delete students table along with data

15.

3. Which of the following is a TCL command

a)

GRANT

b)

UPDATE

c)

ROLLBACK

d)

ALTER

16.

5. ___________ constraint ensures that no two rows have the same value in the specified columns.

a)

Primary Key

b)

Unique

c)

Default

d)

Check

17.

8. ___________ ensure database integrity .

a)

arguments

b)

Constraints

c)

clauses

d)

variable

18.

What is the full form of DDL ?

a)

A.Dynamic Data Language

b)

B.Detailed Data Language

c)

C.Data Definition Language

d)

D.Data Derivation Language

19.

Which SQL function removes extra spaces before and after a string?

a)

CONCAT()

b)

LENGTH()

c)

TRIM()

d)

SUBSTRING()

20.

What is the correct order of clauses in a SQL statement?

a)

SELECT, FROM, ORDER BY, WHERE

b)

SELECT, FROM, WHERE, ORDER BY

c)

SELECT, WHERE, FROM, ORDER BY

d)

WHERE, FROM, SELECT, ORDER BY

21.

Which of these statements will show all wrestlers sorted from the heaviest to the lightest?

a)

SELECT * FROM Wrestler WHERE weight <170;

b)

SELECT * FROM Wrestler WHERE weight >170;

c)

SELECT * FROM Wrestler ORDER BY weight ASC;

d)

SELECT * FROM Wrestler ORDER BY weight DESC;

22.
Which of the following is the correct command to create a view?
a)
CREATE VIEW Inv_1 AS
b)
SELECT VIEW Inv_1 FROM
c)
CREATE TABLE VIEW Inv_1 AS
d)
CREATE VIEW TABLE Inv_1 FROM
23.

A table T_COUNT has 12 number values as 1, 2, 3, 32, 1, 1, null, 24, 12, null, 32, null. Predict the output of the below query.

SELECT COUNT (num) FROM t_count;
a)

12

b)

6

c)

9

d)

Throws exception because COUNT function doesn't works with NULL values

24.

A table T_COUNT has 12 number values as 1, 2, 3, 32, 1, 1, null, 24, 12, null, 32, null. Predict the output of the below query.

SELECT COUNT (DISTINCT num) FROM t_count;
a)

12

b)

6

c)

9

d)

Throws exception because COUNT function doesn't works with NULL values

25.

What does the following code snippet do?

SELECT TOP 5 * FROM students;

a)

Select the top 5 entries for all the columns in the students' table.

b)

Select all the entries from the students' table other than the top 5 entries

c)

Selects all entries from the student table except 5 random rows

d)

None of the above

26.

INSERT INTO EMP VALUES(101,'SUMAN','MANAGER');


Which type of SQL statement is this?

a)

Data Definition Language (DDL)

b)

Data Manipulation Language (DML)

c)

Value statement

d)

Python statement

27.

Which of the following is not a numeric function?

a)

MOD

b)

SIGN

c)

MID

d)

POW

28.

What is the full form of TCL?

a)

Transfer control language

b)

Transportation control language

c)

Transaction control language

d)

Transaction collection language

29.

What is the purpose of the TRUNCATE command in SQL?

a)

To delete all records from a table

b)

To remove a table from the database

c)

To reset the auto-increment value

d)

To create a new table

30.

What does the term 'data integrity' refer to in databases?

a)

The accuracy and consistency of data

b)

The speed of data retrieval

c)

The amount of data stored

d)

The format of data presentation

31.

What is the purpose of the CHECK constraint in SQL?

a)

To provide a default value for a column

b)

To create an index for faster retrieval

c)

To ensure all values in a column are unique

d)

To limit the type of data that can be stored in a column

32.

What does the NOT NULL constraint ensure?

a)

A column can only contain unique values

b)

A column can have duplicate values

c)

A column cannot have NULL values

d)

A column must have a default value

33.

What SQL clause is used to sort the result set?

a)

SELECT

b)

GROUP BY

c)

WHERE

d)

ORDER BY

34.

What is the purpose of normalization in databases?

a)

To increase data redundancy

b)

To improve data retrieval speed

c)

To reduce data redundancy

d)

To enhance data security

35.

Which of the following is a type of database that uses tables to define relationships?

a)

Cloud database

b)

NoSQL database

c)

Relational database

d)

Distributed database