wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SQL - Constraints

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which command is used for removing a table and all its data from the database:

a)

Create command

b)

Drop table command

c)

Alter table command

d)

All of the mentioned

2.

Which constraint(s) can be used to make sure that the column is not left empty?

a)

NOT NULL

b)

UNIQUE

c)

PRIMARY KEY

d)

ALL THE ABOVE

3.
Which of the following is NOT a type of SQL constraint?
a)
Primary Key
b)
Foreign Key
c)
Alternate Key
d)
Unique
e)
NOT NULL
4.

______________ constraint prevents NULL values

a)

UNIQUE

b)

NOT NULL

c)

NULL

d)

FOREIGN KEY

5.

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

a)

Primary Key

b)

Unique

c)

Default

d)

Check

6.

6. ___________ which helps to uniquely identify a record.

a)

Primary key Constraint

b)

Unique Constraint

c)

Default constraint

d)

Check constraint

7.

7. _________ helps to set a limit value placed for a field.

a)

DEFAULT Constraint

b)

Primary Key Constraint

c)

Check Constraint

d)

TABLE CONSTRAINT

8.

A primary key can be NULL in the table? TRUE or FALSE

a)

TRUE

b)

FALSE

9.

SELECT * FROM cars WHERE Doors > 3

would return how many records?

a)

1

b)

2

c)

3

d)

4

10.

SELECT * FROM Students WHERE Gender="Female" AND Class=2.2

would return how many records?

a)

1

b)

2

c)

3

d)

4

11.

What is a ‘tuple’?

a)

A row or record in a database table

b)

Another name for the key linking different tables in a database.

c)

An attribute attached to a record.

d)

Another name for a table in an RDBMS.

12.

With SQL, how can you insert a new record into the "Persons" table?

a)

INSERT ('Jimmy', 'Jackson') INTO Persons

b)

INSERT VALUES ('Jimmy', 'Jackson') INTO Persons

c)

INSERT INTO Persons VALUES ('Jimmy', 'Jackson')

13.

The NOT NULL constraint enforces a column to not accept empty values.


Next ❯

a)

TRUE

b)

FALSE

14.

In the given query which of the keyword has to be inserted?

INSERT INTO employee _____ (1002,Joey,2000);

a)

Table

b)

Values

c)

Relation

d)

Field

15.

CREATE TABLE employee (id INTEGER,name VARCHAR(20),salary NOT NULL);

INSERT INTO employee VALUES (1005,Rach,0);

INSERT INTO employee VALUES (1007,Ross, );

INSERT INTO employee VALUES (1002,Joey,335);


Some of these insert statements will produce an error. Identify the statement.

a)

Insert into employee values (1005,Rach,0);

b)

Insert into employee values (1002,Joey,335);

c)

Insert into employee values (1007,Ross, );

d)

None of the mentioned