wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SQL Statements and Queries

Total questions: 15

Worksheet time: 23mins

Name
Class
Date
1.

What is the correct syntax of inserting to a database

a)

INSERT INTO students (id, name, major) VALUES (1, 'Jane', 'Physics');

b)

insert into students (id, name, major) values (1, 'Jane', 'Physics');

c)

INSERT INTO students (id, name, major) VALUES (1, "Jane", "Physics");

d)

INSERT INTO students (id, name, major) VALUES (1, 'Jane', 'Physics');

e)

INSERT INTO students (id, name, major) VALUES (1, "Jane", "Physics");

2.

What is the correct syntax when creating a primary key

a)

CREATE TABLE Persons (   

ID INT NOT NULL,

LName VARCHAR(255),   

FName VARCHAR(255),

Age INT,

PRIMARY KEY (ID));

b)

CREATE TABLE Persons (   

ID INT NOT NULL PRIMARY KEY,

LName VARCHAR(255),   

FName VARCHAR(255),

Age INT);

c)

CREATE TABLE Persons (   

ID PRIMARY KEY,

LName VARCHAR(255),   

FName VARCHAR(255),

Age INT);

d)

CREATE TABLE Persons (   

ID PK,

LName VARCHAR(255),   

FName VARCHAR(255),

Age INT);

3.

BLOB is a datatype

a)

True

b)

False

4.

Select all that are Constraints

a)

delete

b)

not null

c)

primary key

d)

varchar

e)

all of the above

5.

How do you delete a specific record in students table?

a)

DELETE FROM students WHERE ID=1;

b)

DELETE FROM student WHERE ID=1;

c)

DELETE * FROM students;

d)

DROP TABLE students;

6.

Is it required to define a size for VARCHAR?

a)

True

b)

False

7.

Choose the items that are SQL Functions

a)

SUM()

b)

AVG()

c)

COUNT()

d)

LIKE()

e)

DELETE()

8.

Fill in the correct condition if you want to list all students with the majors Bio and Chemistry:

SELECT * FROM students WHERE major = 'Bio' ____ major = 'Chemistry'

a)

AND

b)

OR

c)

&&

d)

||

9.

What is the correct syntax when updating a name in the employees table?

a)

UPDATE employees SET name = 'Bert';

b)

UPDATE employee SET name = 'Bert';

c)

ALTER table employees SET name = 'Bert';

d)

ALTER table employee SET name = 'Bert';

10.

Is it possible to insert empty values for a column that has NOT NULL constraint?

a)

True

b)

False

11.

What is the default for order for ORDER BY?

a)

ascending

b)

descending

12.

What is the syntax when removing a column from a table?

a)

ALTER TABLE table_name REMOVE COLUMN column_name;

b)

ALTER TABLE table_name DROP COLUMN column_name;

c)

ALTER TABLE table_name DELETE COLUMN column_name;

d)

all of the above

13.

It is used to filter records from a single table

a)

WHERE

b)

UNION

c)

INNER JOIN

d)

OUTER JOIN

14.

is used to combine results from two or more tables

a)

INNER JOIN

b)

OUTER JOIN

c)

UNION

d)

WHERE

15.

What does this statement do:

SELECT name, age FROM employees ORDER BY 1;

a)

sorts query result by name in ascending order

b)

sorts query result by name in descending order

c)

sorts query result by age in ascending order

d)

sorts query result by age in descending order