Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Introduction to SQL

Total questions: 8

Worksheet time: 8mins

Name
Class
Date
1.

How many possible states are there for a Boolean column?

a)

1

b)

2

c)

3

d)

4

2.

What is the difference of Varchar type and Text type?

a)

No difference

b)

Varchar length can be specified but not Text

c)

Text length can be specified but not Varchar

d)

Varchar can take special character but not Text

3.

Which of the following is true?

a)

SQL syntax in PostgreSQL for SELECT, WHERE statements are case sensitive

b)

date / timestamp columns can be cast to a Varchar

c)

We can select columns with null by doing

Select * from Table where Col1 = Null

d)

Postgresql supports addition, subtraction, multiplication, but not division.

4.

What is the output for the following?

SELECT CAST(EXTRACT(Month FROM TIMESTAMP '2016-11-31 13:30:15') as varchar)

a)

November

b)

No output - syntax error

c)

"11"

d)

11

5.

How to correctly truncate a month from timestamp?

a)

SELECT DATE_TRUNCATE('month', TIMESTAMP '2017-03-17 02:09:30')

b)

SELECT DATE_TRUNC(month, TIMESTAMP '2017-03-17 02:09:30')

c)

SELECT DATE_TRUNCATE(TIMESTAMP '2017-03-17 02:09:30','month')

d)

SELECT DATE_TRUNC('month', TIMESTAMP '2017-03-17 02:09:30')

6.

Which of the following is correct PostgrSQL syntax?

a)

select *

from fast_food.orders

where food='fries'

order by 1

limit 3

b)

select *

from fast_food.orders

where food='fries'

limit 3

order by 1

c)

select *

from fast_food.orders

limit 3

order by 1

where food='fries'

d)

select *

from fast_food.orders

where food='fries'

limit 3

order by 1

7.

How to correctly use a LIKE operator to search for text containing "Abc"?

a)

Select * from Table where text LIKE %Abc%

b)

Select * from Table where text LIKE '$Abc$'

c)

Select * from Table where text LIKE '%Abc%'

d)

Select * from Table where text LIKE ~Abc~

8.

What is not a right way to handle NULL values?

a)

Order by so NULLS will appear last

b)

use WHERE filter where Col1 is not NULL

c)

Coalesce the NULL value to become another value such as 0

d)

cast Null as INT type to get 0