wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

sql test

Total questions: 180

Worksheet time: 2hrs 35mins

Name
Class
Date
1.

Which SQL function is used to count the number of rows in a SQL query?

a)

COUNT()

b)

NUMBER()

c)

SUM()

d)

COUNT(*)

2.

Which of the following SQL clauses is used to DELETE tuples from a database table?

a)

DELETE

b)

REMOVE

c)

DROP

d)

CLEAR

3.

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

4.

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%’

5.

What does the ALTER TABLE clause do?

a)

The SQL ALTER TABLE clause modifies a table definition by altering, adding, or deleting table columns and/or constraints

b)

The SQL ALTER TABLE clause is used to insert data into database table

c)

THE SQL ALTER TABLE deletes data from database table

d)

The SQL ALTER TABLE clause is used to delete a database table

6.

The UPDATE SQL clause can _____________

a)

update only one row at a time

b)

update more than one row at a time

c)

delete more than one row at a time

d)

delete only one row at a time

7.

How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?

a)

UPDATE Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’

b)

MODIFY Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’

c)

MODIFY Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’

d)

UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’

8.

SQL query to find all the cities whose humidity is 95.

a)

SELECT city WHERE humidity = 95

b)

SELECT city FROM weather WHERE humidity = 95

c)

SELECT humidity = 89 FROM weather

d)

SELECT city FROM weather

9.

SQL query to find the temperature in increasing order of all cities.

a)

SELECT city FROM weather ORDER BY temperature

b)

SELECT city, temperature FROM weather

c)

SELECT city, temperature FROM weather ORDER BY temperature

d)

SELECT city, temperature FROM weather ORDER BY city

10.

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

11.

The command to remove rows from a table ‘CUSTOMER’ is __________________

a)

DROP FROM CUSTOMER

b)

UPDATE FROM CUSTOMER

c)

REMOVE FROM CUSTOMER

d)

DELETE FROM CUSTOMER WHERE

12.

Find the names of these cities with temperature and condition whose condition is neither sunny nor cloudy.

a)

SELECT city, temperature, condition FROM weather WHERE condition NOT IN (‘sunny’, ‘cloudy’)

b)

SELECT city, temperature, condition FROM weather WHERE condition NOT BETWEEN (‘sunny’, ‘cloudy’)

c)

SELECT city, temperature, condition FROM weather WHERE condition IN (‘sunny’, ‘cloudy’)

d)

SELECT city, temperature, condition FROM weather WHERE condition BETWEEN (‘sunny’, ‘cloudy’);

13.

SQL is

a)

Structured Query Language

b)

Simple Query Language

c)

Structured Question Language

d)

Structure Quality Language

14.

DDL means

(a)  

15.

DML

(a)  

16.

To remove a record from a table which SQL statement would you use?

a)

Remove

b)

Cancel

c)

Delete

d)

Eradicate

17.

In order to modify data in a database we would use which SQL statement?

a)

Update

b)

Amend

c)

Alter

d)

Modify

18.

Which statement is used to extract data from a database?

a)

Extract

b)

Get

c)

Open

d)

Select

19.

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

a)

Add To

b)

Update To

c)

Add Into

d)

Insert Into

20.

Less than or equal to?

a)

>=

b)

=>

c)

=<

d)

<=

21.

Which word is missing from the following SQL statement?


Select * table_name

a)

With

b)

Where

c)

From

d)

And

22.

Which SQL statement would add a record to the database?

a)

INSERT INTO Designer VALUES ('SMI01', 'M Smith', 'mail@msmith.com', '01224123456')

b)

INSERT VALUES ('SMI01', 'M Smith', 'mail@msmith.com', 01224123456') INTO Designer

c)

INSERT ('SMI01', 'M Smith', 'mail@msmith.com', '01224123456') INTO Designer

d)

INSERT Designer INTO VALUES (''SMI01', 'M Smith', 'mail@msmith.com', '01224123456')

23.

Where does the CREATE Command belong?

a)

DML

b)

DDL

c)

DCL

24.

It is a DML command that is used to display record.

a)

DISPLAY

b)

STRUCTURE

c)

WHERE

d)

SELECT

25.

Referential Integrity is

a)

System of rules

b)

System of data

c)

Table constraints

d)

is related to Primary key

26.

______________ constraint prevents NULL values

a)

UNIQUE

b)

NOT NULL

c)

NULL

d)

FOREIGN KEY

27.

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

a)

TRUE

b)

FALSE

28.

What does "SQL" stand for?

a)

Structured Question Language

b)

Structured Query Language

c)

Simple Query Language

d)

Simple Question Language

29.

Which statement is used to extract data from a database?

a)

Extract

b)

Get

c)

Open

d)

Select

30.

If you were wanting to filter data, which clause would you use?

a)

Where

b)

Order by

c)

From

d)

Select

31.

Using which word allows you to specify that more than one condition must be met in a query?

a)

Also

b)

And

c)

Or

d)

Where

32.

Using which word allows you to specify that only one of a series of conditions needs to be met in a query filter?

a)

And

b)

Maybe

c)

If

d)

Or

33.

In order to amend data in a database we would use which SQL statement?

a)

Update

b)

Amend

c)

Alter

d)

Modify

34.

To remove a record from a table which SQL statement would you use?

a)

Remove

b)

Cancel

c)

Delete

d)

Eradicate

35.

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

a)

Add To

b)

Update To

c)

Add Into

d)

Insert Into

36.

Less than or equal to?

a)

>=

b)

=>

c)

=<

d)

<=

37.

Which character returns all the data found in a table?

a)

%

b)

#

c)

*

d)

/

38.

Which word is missing from the following SQL statement?


Select * table_name

a)

With

b)

Where

c)

From

d)

And

39.

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

40.

How do we select all rows for the "Designer" table?

a)

SELECT * FROM Designer

b)

SELECT [All] FROM Designer

c)

SELECT Designer.*

d)

SELECT FROM Designer

41.

How would we script a SQL query to select "Description" from the Item table?

a)

SELECT Item.Description

b)

EXTRACT Description FROM Item

c)

SELECT Item FROM Description

d)

SELECT Description FROM Item

42.

Which query would return only the fields DesignerID and Designer?

a)

SELECT * FROM Designers

b)

SELECT DesignerID, Name FROM Designers

c)

SELECT DesignerID AND Designer FROM Designers

d)

SELECT DesignerID, Designer FROM Designers

43.

You are required to update the phone number for only the DesignerID "SMI01" in the "Designer" table. Which of these would successfully do that?

a)

UPDATE Designer SET PhoneNo = '01224123456'

b)

UPDATE Designer (PhoneNo) VALUES ('01224123456')

c)

UPDATE Designer SET PhoneNo = '01224123456' WHERE DesignerID = 'SMI01'

d)

UPDATE PhoneNo = '01224123456' FROM Designer WHERE DesignerID = 'SMI01'

44.

With SQL how can I return all items in the Item table sorted from the lowest priced to the highest priced?

a)

SELECT * FROM Items ORDER BY Price ASCENDING

b)

SELECT * FROM Items ORDER BY Price ASC

c)

SELECT * FROM Items BY Price LOWEST TO HIGHEST

d)

SELECT * FROM Items ORDER BY Price DESC

45.

How would you DELETE records from the Items table with a "Chair" Type?

a)

DELETE 'Chair' FROM Items

b)

DELETE Type FROM Items WHERE Type = 'Chair'

c)

DELETE FROM Items WHERE Type = 'Chair'

d)

DELETE ITEMS WHERE Type = 'Chair'

46.

How would you display Chairs in the Items table that have a Price greater than £50.

a)

SELECT * FROM Items WHERE Type = 'Chair' AND Price > 50

b)

SELECT * FROM Items WHERE Type = 'Chair' OR Price < 100

c)

SELECT * FROM Iterms WHERE Type = 'Chair' AND Price >= 50

d)

SELECT * FROM Items WHERE Price > 50

47.

Which SQL statement would add a record to the database?

a)

INSERT INTO Designer VALUES ('SMI01', 'M Smith', 'mail@msmith.com', '01224123456')

b)

INSERT VALUES ('SMI01', 'M Smith', 'mail@msmith.com', 01224123456') INTO Designer

c)

INSERT ('SMI01', 'M Smith', 'mail@msmith.com', '01224123456') INTO Designer

d)

INSERT Designer INTO VALUES (''SMI01', 'M Smith', 'mail@msmith.com', '01224123456')

48.

What does SQL stand for?

a)

Standard Query Language

b)

Sequential Query Language

c)

Structured Question Language

d)

Structured Query Language

49.

Match the following SQL term with a description - FROM

a)

The criteria which must be met

b)

The fields to display

c)

The field and order used to sort the results

d)

The table used in the query

50.

Match the following SQL term with a description - SELECT

a)

The fields to display

b)

The table used in the query

c)

The criteria which must be met

d)

The field and order used to sort the results

51.

Match the following SQL term with a description - WHERE

a)

The table used in the query

b)

The fields to display

c)

The field and order used to sort the results

d)

The criteria which must be set

52.

Match the following SQL term with a description - ORDER BY

a)

The fields to display

b)

The field and order used to sort the results

c)

The table used in the query

d)

The criteria that must be met

53.

In what order does SQL process the instructions?

a)

FROM - SELECT - WHERE - ORDER BY

b)

WHERE - FROM - SELECT - ORDER BY

c)

SELECT - FROM - WHERE - ORDER BY

d)

SELECT - FROM - ORDER By - WHERE

54.

What is a field?

a)

A collection of information

b)

A single item of information

c)

A list of information

d)

A group of records

55.

Which of the following is not a database data type?

a)

text

b)

number

c)

array

d)

date

56.

Which example of the field name below is in camel case?

a)

First Name

b)

firstName

c)

FIRSTNAME

d)

firstname

57.

Which symbol would you use to represent more than 50

a)

= 50

b)

< 50

c)

> 50

d)

# 50

58.

What does "SQL" stand for?

a)

Structured Question Language

b)

Structured Query Language

c)

Simple Query Language

d)

Simple Question Language

59.

Which statement is used to extract data from a database?

a)

Extract

b)

Get

c)

Open

d)

Select

60.

Using which word allows you to specify that more than one condition must be met in a query?

a)

Also

b)

And

c)

Or

d)

Where

61.

In order to amend data in a database we would use which SQL statement?

a)

Update

b)

Amend

c)

Alter

d)

Modify

62.

To remove a record from a table which SQL statement would you use?

a)

Remove

b)

Cancel

c)

Delete

d)

Eradicate

63.

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

a)

Add To

b)

Update To

c)

Add Into

d)

Insert Into

64.

Less than or equal to?

a)

>=

b)

=>

c)

=<

d)

<=

65.

Which character returns all the data found in a table?

a)

%

b)

#

c)

*

d)

/

66.

Which word is missing from the following SQL statement?


Select * table_name

a)

With

b)

Where

c)

From

d)

And

67.

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

68.

What is a field?

a)

A collection of information

b)

A single item of information

c)

A list of information

d)

A group of records

69.

What does "SQL" stand for?

a)

Structured Question Language

b)

Structured Query Language

c)

Simple Query Language

d)

Simple Question Language

70.

Which statement is used to extract data from a database?

a)

Extract

b)

Get

c)

Open

d)

Select

71.

To remove a record from a table which SQL statement would you use?

a)

Remove

b)

Cancel

c)

Delete

d)

Eradicate

72.

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

a)

Add To

b)

Update To

c)

Add Into

d)

Insert Into

73.

Less than or equal to?

a)

>=

b)

=>

c)

=<

d)

<=

74.

Which character returns all the data found in a table?

a)

%

b)

#

c)

*

d)

/

75.

Which word is missing from the following SQL statement?


Select * table_name

a)

With

b)

Where

c)

From

d)

And

76.

How do we select all rows for the "Designer" table?

a)

SELECT * FROM Designer

b)

SELECT [All] FROM Designer

c)

SELECT Designer.*

d)

SELECT FROM Designer

77.

How would we script a SQL query to select "Description" from the Item table?

a)

SELECT Item.Description

b)

EXTRACT Description FROM Item

c)

SELECT Item FROM Description

d)

SELECT Description FROM Item

78.

You are required to update the phone number for only the DesignerID "SMI01" in the "Designer" table. Which of these would successfully do that?

a)

UPDATE Designer SET PhoneNo = '01224123456'

b)

UPDATE Designer (PhoneNo) VALUES ('01224123456')

c)

UPDATE Designer SET PhoneNo = '01224123456' WHERE DesignerID = 'SMI01'

d)

UPDATE PhoneNo = '01224123456' FROM Designer WHERE DesignerID = 'SMI01'

79.

With SQL how can I return all items in the Item table sorted from the lowest priced to the highest priced?

a)

SELECT * FROM Items ORDER BY Price ASCENDING

b)

SELECT * FROM Items ORDER BY Price ASC

c)

SELECT * FROM Items BY Price LOWEST TO HIGHEST

d)

SELECT * FROM Items ORDER BY Price DESC

80.

How would you DELETE records from the Items table with a "Chair" Type?

a)

DELETE 'Chair' FROM Items

b)

DELETE Type FROM Items WHERE Type = 'Chair'

c)

DELETE FROM Items WHERE Type = 'Chair'

d)

DELETE ITEMS WHERE Type = 'Chair'

81.

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

82.

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%’

83.

What does the ALTER TABLE clause do?

a)

The SQL ALTER TABLE clause modifies a table definition by altering, adding, or deleting table columns and/or constraints

b)

The SQL ALTER TABLE clause is used to insert data into database table

c)

THE SQL ALTER TABLE deletes data from database table

d)

The SQL ALTER TABLE clause is used to delete a database table

84.

The UPDATE SQL clause can _____________

a)

update only one row at a time

b)

update more than one row at a time

c)

delete more than one row at a time

d)

delete only one row at a time

85.

How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?

a)

UPDATE Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’

b)

MODIFY Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’

c)

MODIFY Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’

d)

UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’

86.

Find the names of these cities with temperature and condition whose condition is neither sunny nor cloudy.

a)

SELECT city, temperature, condition FROM weather WHERE condition NOT IN (‘sunny’, ‘cloudy’)

b)

SELECT city, temperature, condition FROM weather WHERE condition NOT BETWEEN (‘sunny’, ‘cloudy’)

c)

SELECT city, temperature, condition FROM weather WHERE condition IN (‘sunny’, ‘cloudy’)

d)

SELECT city, temperature, condition FROM weather WHERE condition BETWEEN (‘sunny’, ‘cloudy’);

87.

In what order does SQL process the instructions?

a)

FROM - SELECT - WHERE - ORDER BY

b)

WHERE - FROM - SELECT - ORDER BY

c)

SELECT - FROM - WHERE - ORDER BY

d)

SELECT - FROM - ORDER By - WHERE

88.

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

a)

TRUE

b)

FALSE

89.

Which statement will show all fields and records from the table called "celebs"?

a)

SELECT * FROM celebs;

b)

SELECT FROM celebs;

c)

SELECT forename, surname FROM celebs;

d)

SELECT celebs;

90.

The SQL statement being run is:


SELECT player_name, score FROM leaderboard;


What is the name of the table in this query?

a)

SELECT

b)

player_name

c)

score

d)

leaderboard

91.

The SQL statement being run is:


SELECT player_name, score FROM leaderboard;


How many columns of results will be shown when this query is run?

a)

0

b)

1

c)

2

d)

3

92.

Which SQL statement will show the names and heights of all basketball players taller than 200?

a)

SELECT name FROM Player WHERE height >200;

b)

SELECT name FROM Player WHERE height >=200;

c)

SELECT name, height FROM Player WHERE height >200;

d)

SELECT name, height FROM Player WHERE height <200;

93.

Which SQL statement will show the names and weights of all wrestlers lighter than 170?

a)

SELECT name, weight FROM Wrestler WHERE weight >170;

b)

SELECT name, weight FROM Wrestler WHERE weight <= 170;

c)

SELECT name, weight FROM Wrestler WHERE weight <170;

d)

SELECT name, weight FROM Wrestler WHERE weight >=170;

94.

Which character always appears at the end of a SQL statement?

a)

;

b)

:

c)

,

d)

.

95.

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;

96.

Which of these statements will show all wrestlers in alphabetical order of their name

a)

SELECT * FROM Wrestler ORDER BY name ASC;

b)

SELECT * FROM Wrestler ORDER BY name DESC;

c)

SELECT * FROM Wrestler ORDER BY weight ASC;

d)

SELECT * FROM Wrestler ORDER BY weight DESC;

97.

Which SQL statement will show the names and heights of all basketball players sorted from smallest to tallest?

a)

SELECT name FROM Player ORDER BY height ASC;

b)

SELECT name FROM Player ORDER BY height DESC;

c)

SELECT name, height FROM Player ORDER BY height ASC;

d)

SELECT name, height FROM Player ORDER BY height DESC;

98.

The SQL statement that was run was:


SELECT username, score FROM Player WHERE score>900;


The results were:


andy_pandy_12 911

aleeyah_nasoor_09 920

new_slang 907

utter_mess 901


How many records were returned in the query results?

a)

2

b)

3

c)

4

d)

8

99.

What does SQL stand for?

a)

Structured Query Language

b)

Strong Question Language

c)

Structured Question Language

100.

The language used application programs to request data from the DBMS is referred to as __________

a)

DDL

b)

DML

c)

Query Language

d)

All of the mentioned

101.

Match SQL language with SQL commands

1)DDL i)Revok, Grant

2)DML ii)rename a table

3)TCL iii)insert, update

4)DCL iv)rollback , commit

a)

1-iii,2-i,3-ii,4-iv

b)

1-iii,2-ii,3-iv,4-i

c)

1-ii,2-iii,3-iv,4-i

d)

1-i,2-iii,3-ii,4-iv

102.

Which of the following is not a type of SQL statement?

a)

Data Manipulation Language (DML)

b)

Data Definition Language (DDL)

c)

Data Control Language (DCL)

d)

Data Communication Language (DCL)

103.

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

104.

SQL Query to delete all rows in a table without deleting the table (structure, attributes, and indexes)

a)

DELETE FROM table_name;

b)

DELETE TABLE table_name;

c)

DROP TABLE table_name;

d)

None

105.

Correct syntax query syntax to drop a column from a table is

a)

DELETE COLUMN column_name;

b)

DROP COLUMN column_name;

c)

ALTER TABLE table_name DROP COLUMN column_name;

d)

None is correct.

106.

SQL has how many main commands for DDL:

a)

1

b)

2

c)

3

d)

4

107.

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

108.

Which of the following language is used to specify database Schema ?

a)

DDL

b)

DML

c)

DCL

d)

None

109.

DDL Stands for ___________.

a)

Data Management Language

b)

Data Manupulation Language

c)

Data Development Language

d)

Data Definition Language

110.

SQL is

a)

Structured Query Language

b)

Simple Query Language

c)

Structured Question Language

d)

Structure Quality Language

111.

To remove a record from a table which SQL statement would you use?

a)

Remove

b)

Cancel

c)

Delete

d)

Eradicate

112.

In order to modify data in a database we would use which SQL statement?

a)

Update

b)

Amend

c)

Alter

d)

Modify

113.

Which statement is used to extract data from a database?

a)

Extract

b)

Get

c)

Open

d)

Select

114.

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

a)

Add To

b)

Update To

c)

Add Into

d)

Insert Into

115.

Less than or equal to?

a)

>=

b)

=>

c)

=<

d)

<=

116.

Which word is missing from the following SQL statement?


Select * table_name

a)

With

b)

Where

c)

From

d)

And

117.

Which SQL statement would add a record to the database?

a)

INSERT INTO Designer VALUES ('SMI01', 'M Smith', 'mail@msmith.com', '01224123456')

b)

INSERT VALUES ('SMI01', 'M Smith', 'mail@msmith.com', 01224123456') INTO Designer

c)

INSERT ('SMI01', 'M Smith', 'mail@msmith.com', '01224123456') INTO Designer

d)

INSERT Designer INTO VALUES (''SMI01', 'M Smith', 'mail@msmith.com', '01224123456')

118.

It is a DML command that is used to display record.

a)

DISPLAY

b)

STRUCTURE

c)

WHERE

d)

SELECT

119.

______________ constraint prevents NULL values

a)

UNIQUE

b)

NOT NULL

c)

NULL

d)

FOREIGN KEY

120.

Which of the following SQL clauses is used to DELETE tuples from a database table?

a)

DELETE

b)

REMOVE

c)

DROP

d)

CLEAR

121.

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

122.

How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?

a)

UPDATE Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’

b)

MODIFY Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’

c)

MODIFY Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’

d)

UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’

123.

SQL query to find all the cities whose humidity is 95.

a)

SELECT city WHERE humidity = 95

b)

SELECT city FROM weather WHERE humidity = 95

c)

SELECT humidity = 89 FROM weather

d)

SELECT city FROM weather

124.

Using which word allows you to specify that more than one condition must be met in a query?

a)

Also

b)

And

c)

Or

d)

Where

125.

Using which word allows you to specify that only one of a series of conditions needs to be met in a query filter?

a)

And

b)

Maybe

c)

If

d)

Or

126.

Which character returns all the data found in a table?

a)

%

b)

#

c)

*

d)

/

127.

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

128.

How do we select all rows for the "Designer" table?

a)

SELECT * FROM Designer

b)

SELECT [All] FROM Designer

c)

SELECT Designer.*

d)

SELECT FROM Designer

129.

How would we script a SQL query to select "Description" from the Item table?

a)

SELECT Item.Description

b)

EXTRACT Description FROM Item

c)

SELECT Item FROM Description

d)

SELECT Description FROM Item

130.

With SQL how can I return all items in the Item table sorted from the lowest priced to the highest priced?

a)

SELECT * FROM Items ORDER BY Price ASCENDING

b)

SELECT * FROM Items ORDER BY Price ASC

c)

SELECT * FROM Items BY Price LOWEST TO HIGHEST

d)

SELECT * FROM Items ORDER BY Price DESC

131.

How would you display Chairs in the Items table that have a Price greater than £50.

a)

SELECT * FROM Items WHERE Type = 'Chair' AND Price > 50

b)

SELECT * FROM Items WHERE Type = 'Chair' OR Price < 100

c)

SELECT * FROM Iterms WHERE Type = 'Chair' AND Price >= 50

d)

SELECT * FROM Items WHERE Price > 50

132.

Match the following SQL term with a description - WHERE

a)

The table used in the query

b)

The fields to display

c)

The field and order used to sort the results

d)

The criteria which must be set

133.

Match the following SQL term with a description - ORDER BY

a)

The fields to display

b)

The field and order used to sort the results

c)

The table used in the query

d)

The criteria that must be met

134.

What is a field?

a)

A collection of information

b)

A single item of information

c)

A list of information

d)

A group of records

135.

Which of the following is not a database data type?

a)

text

b)

number

c)

array

d)

date

136.

Which example of the field name below is in camel case?

a)

First Name

b)

firstName

c)

FIRSTNAME

d)

firstname

137.

What would the SQL query pictured do?

a)

Find all the men

b)

Find all of the female writers

c)

Find all of Elgar's friends

d)

Find all the male writers

e)

Find all the fish

138.

Which of the queries is most likely to have produced this result?

a)

ANSWER: SELECT id, name, year FROM movies WHERE year > 2010;

b)

ANSWER: SELECT id, name, year FROM movies WHERE year < 2010;

c)

ANSWER: SELECT * FROM movies WHERE year > 2010;

d)

ANSWER: SELECT id, name, year FROM movies WHERE YEAR > 2010;

139.
What is missing in this code? SELECT * FROM WHERE genre = ‘action’ ORDER BY year ASC;
a)
Missing an AND
b)
Table name
c)
Capitalize action
d)
None of these
140.

To create a CHECK constraint on the "Age" column when the table "Persons" is already created, which SQL will be used:

a)

ALTER TABLE Persons

ADD CHECK (Age>=18);

b)

CREATE TABLE Persons

ADD CHECK (Age>=18);

c)

CREATE TABLE Persons

CONSTRAINT (Age>=18);

d)

DROP TABLE Persons

CONSTRAINT (Age>=18);

141.

To drop a UNIQUE constraint, use the following SQL:


ALTER TABLE Persons

________ CONSTRAINT UC_Person;

a)

DROP

b)

UPDATE

c)

DELETE

d)

REMOVE

142.

Write the correct SQL statement to create a new table called Persons.

______________ (

PersonID int,

LastName varchar(255),

FirstName varchar(255),

Address varchar(255),

City varchar(255)

);

a)

UPDATE TABLE Persons

b)

ALTER TABLE Persons

c)

CREATE TABLE Persons

d)

CREATE TABLE AS PEOPLE

143.

The following SQL ensures that the "ID", "LastName", and "FirstName" columns will NOT accept NULL values when the "Persons" table is created:


CREATE TABLE Persons (

ID int _______ ,

LastName varchar(255) ________ ,

FirstName varchar(255) _________,

Age int

);

a)

NOT NULL for first blank only and others are NULL

b)

NOT NULL for all 3 blanks

c)

NULL for all 3 blanks

d)

none of the answers

144.

The _________ constraint is used to set a default value for a column.

The default value will be added to all new records, if no other value is specified.

a)

NULL

b)

DEFAULT

c)

CHECK

d)

UNKNOWN

145.

What do the letters in CRUD stand for?

a)

Create Read Update Delete

b)

Craft Run Upload Database

c)

Create Run Unrun Data

d)

Crunch Read Uptime Downtime

146.

Which statement is used to extract data from a database?

a)

EXTRACT

b)

GET

c)

OPEN

d)

SELECT

147.

To remove a record from a table, which SQL statement would you use?

a)

REMOVE

b)

DELETE

c)

CANCEL

d)

ERADICATE

148.

What's one solid reason for us to use databases instead of just storing stuff in a variable on the server?

a)

If the server goes down, we won't lose all our data--our data will persist between sessions

b)

A database is a more compact way of storing the information

c)

Accessing information from a database is faster than accessing information from a variable

d)

It's a toss-up, really--they're both good ways of storing information

149.

Using which word allows you to specify that MORE THAN ONE condition must be met in a query?

a)

OR

b)

WHERE

c)

AND

d)

SELECT

150.

I want to create a table in my table named "actors" with two columns: "name" and "age." What statement will do this?

a)

CREATE TABLE actors (name TEXT, age INTEGER);

b)

CREATE actors WITH COLUMNS (name, age);

c)

CREATE DATABASE actors WITH COLUMNS (name TEXT, age INTEGER);

d)

CREATE actors (name, age): TABLE, TEXT, INTEGER;

151.

I want to add the actor "Brad Pitt" (aged 56) to my table "actors." Which statement will do this?

a)

INSERT INTO actors VALUES ("Brad Pitt", 56);

b)

INSERT "Brad Pitt" AND 56 INTO actors;

c)

UPDATE age = 56 WHERE name = "Brad Pitt";

d)

CREATE ENTRY ("Brad Pitt", 56) IN TABLE actors;

152.

I want to select EVERY column and entry in my "actors" table. How can I do that?

a)

SELECT * FROM actors;

b)

SELECT age FROM actors;

c)

SELECT * FROM actors WHERE age > 30;

d)

SELECT name, age FROM actors WHERE age < 30;

153.

I want to select all columns in my "actors" table for all actors older than 30. How can I do that?

a)

SELECT * FROM actors;

b)

SELECT age FROM actors;

c)

SELECT * FROM actors WHERE age > 30;

d)

SELECT name, age FROM actors WHERE age < 30;

154.

Which aggregate function would I want to use to see which actor in my table is the oldest?

a)

SUM

b)

MAX

c)

GROUP BY

d)

WHERE

155.
What word is missing from the line below?
SELECT *
_______ CUSTOMER;
a)
FROM
b)
WHERE
c)
SELECT
d)
ORDER BY
156.
What does “SQL” stand for?
a)
Standard Query Language.
b)
Structured Query Language.
c)
Structured Quick-access Language.
d)
Standard Questioning Language.
157.
What does a Relationship do within a database?
a)
It reduces data redundancy by linking fields in different tables.
b)
It shows which users in a database are related.
c)
It increases data redundancy by linking fields in different tables.
d)
The fields are the vertical columns in a table.
158.
What is data redundancy?
a)
Data that is repeated multiple times.
b)
Data that is safe from SQL attacks.
c)
Data that is weak to SQL attacks.
d)
Data that has no use anymore.
159.

With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" is "Peter"?

a)

SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'

b)

SELECT [all] FROM Persons WHERE FirstName='Peter'

c)

SELECT * FROM Persons WHERE FirstName<>'Peter'

d)

SELECT * FROM Persons WHERE FirstName='Peter'

160.

What word is missing from the line below?

SELECT * _______ CUSTOMER WHERE Name = "Bob";

a)

FROM

b)

WHERE

c)

SELECT

d)

ORDER BY

161.

To remove a record from a table which SQL statement would you use?

a)

Remove

b)

Cancel

c)

Delete

d)

Eradicate

162.

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

a)

Add To

b)

Update To

c)

Add Into

d)

Insert Into

163.

Less than or equal to?

a)

>=

b)

=>

c)

=<

d)

<=

164.

Which SQL statement would add a record to the database?

a)

INSERT INTO Designer VALUES ('SMI01', 'M Smith', 'mail@msmith.com', '01224123456')

b)

INSERT VALUES ('SMI01', 'M Smith', 'mail@msmith.com', 01224123456') INTO Designer

c)

INSERT ('SMI01', 'M Smith', 'mail@msmith.com', '01224123456') INTO Designer

d)

INSERT Designer INTO VALUES (''SMI01', 'M Smith', 'mail@msmith.com', '01224123456')

165.

How many fields are there?

a)

4

b)

5

c)

6

d)

7

166.

How many records are in this table?

a)

7

b)

6

c)

5

d)

4

167.

With SQL, how do you select a column named "FirstName" from a table named "Persons"?

a)

EXTRACT FirstName FROM Persons

b)

SELECT Persons.FirstName

c)

SELECT FirstName FROM Persons

d)

SELECT * FROM Persons

168.

Which word is missing from the following SQL statement?


Select * table_name

a)

With

b)

Where

c)

From

d)

And

169.

Which SQL function is used to count the number of rows in a SQL query?

a)

COUNT()

b)

NUMBER()

c)

SUM()

d)

COUNT(*)

170.

Which of the following SQL clauses is used to DELETE tuples from a database table?

a)

DELETE

b)

REMOVE

c)

DROP

d)

CLEAR

171.

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

172.

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%’

173.

What does the ALTER TABLE clause do?

a)

The SQL ALTER TABLE clause modifies a table definition by altering, adding, or deleting table columns and/or constraints

b)

The SQL ALTER TABLE clause is used to insert data into database table

c)

THE SQL ALTER TABLE deletes data from database table

d)

The SQL ALTER TABLE clause is used to delete a database table

174.

The UPDATE SQL clause can _____________

a)

update only one row at a time

b)

update more than one row at a time

c)

delete more than one row at a time

d)

delete only one row at a time

175.

How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?

a)

UPDATE Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’

b)

MODIFY Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’

c)

MODIFY Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’

d)

UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’

176.

SQL query to find all the cities whose humidity is 95.

a)

SELECT city WHERE humidity = 95

b)

SELECT city FROM weather WHERE humidity = 95

c)

SELECT humidity = 89 FROM weather

d)

SELECT city FROM weather

177.

SQL query to find the temperature in increasing order of all cities.

a)

SELECT city FROM weather ORDER BY temperature

b)

SELECT city, temperature FROM weather

c)

SELECT city, temperature FROM weather ORDER BY temperature

d)

SELECT city, temperature FROM weather ORDER BY city

178.

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

179.

The command to remove rows from a table ‘CUSTOMER’ is __________________

a)

DROP FROM CUSTOMER

b)

UPDATE FROM CUSTOMER

c)

REMOVE FROM CUSTOMER

d)

DELETE FROM CUSTOMER WHERE

180.

Find the names of these cities with temperature and condition whose condition is neither sunny nor cloudy.

a)

SELECT city, temperature, condition FROM weather WHERE condition NOT IN (‘sunny’, ‘cloudy’)

b)

SELECT city, temperature, condition FROM weather WHERE condition NOT BETWEEN (‘sunny’, ‘cloudy’)

c)

SELECT city, temperature, condition FROM weather WHERE condition IN (‘sunny’, ‘cloudy’)

d)

SELECT city, temperature, condition FROM weather WHERE condition BETWEEN (‘sunny’, ‘cloudy’);