0
0
PostgreSQLquery~5 mins

VALUES clause for inline data in PostgreSQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the VALUES clause do in SQL?
The VALUES clause lets you create a set of rows with specified data directly inside a query, without needing a table.
Click to reveal answer
beginner
How do you write a simple VALUES clause with two rows of data?
Use VALUES followed by rows in parentheses, separated by commas. Example: VALUES (1, 'apple'), (2, 'banana')
Click to reveal answer
intermediate
Can you use the VALUES clause as a table in a SELECT statement?
Yes, you can treat the VALUES clause like a temporary table and select from it using an alias.
Click to reveal answer
intermediate
Why might you use the VALUES clause instead of creating a temporary table?
VALUES is quick and simple for small sets of data you want to use just once, without creating or managing a table.
Click to reveal answer
intermediate
How do you assign column names to data from a VALUES clause?
Use an alias with column names after the VALUES clause. Example: VALUES (1, 'a') AS t(id, letter)
Click to reveal answer
What keyword starts the inline data list in SQL?
AROWS
BDATA
CVALUES
DINLINE
How do you separate multiple rows in a VALUES clause?
AWith semicolons (;)
BWith periods (.)
CWith colons (:)
DWith commas (,)
Which of these is a valid way to use VALUES in a SELECT?
ASELECT * FROM (VALUES (1, 'x'), (2, 'y')) AS t(id, letter)
BSELECT * FROM VALUES (1, 'x'), (2, 'y')
CVALUES SELECT (1, 'x'), (2, 'y')
DFROM VALUES (1, 'x'), (2, 'y') SELECT *
What is a good reason to use VALUES instead of a table?
ATo quickly test or use small sets of data inline
BTo store large amounts of data permanently
CTo create indexes automatically
DTo backup data
How do you name columns when using VALUES inline?
AUse AS with the VALUES keyword
BUse an alias with column names after VALUES in parentheses
CYou cannot name columns in VALUES
DUse the COLUMN keyword
Explain how to use the VALUES clause to create inline data and select from it.
Think about how to write rows and give them names to use like a table.
You got /5 concepts.
    Describe a situation where using the VALUES clause is better than creating a temporary table.
    When you want to avoid extra setup and just use some data once.
    You got /4 concepts.