Prepstellar

SQL Fundamentals · Practice set 6 of 7

SQL Lexical Structure: 10 practice questions

10 questions · Untimed · Free

10 free SQL Fundamentals practice questions on SQL Lexical Structure, with an explanation for every answer. Untimed. The full mock exam and the timed version are in the app.

Set 6 · SQL Lexical Structure · 10 questions Read the lesson
  1. Question 1 of 10

    Which character normally terminates an SQL command?

    1. AA semicolon
    2. BA period
    3. CA comma
    4. DA double dash
    Show the answer

    A semicolon closes the current command; the end of the input stream can also terminate one, while a double dash begins a line comment.

    Next → 1 / 10
  2. Question 2 of 10

    How is a quoted identifier delimited?

    1. AWith single quotes
    2. BWith paired commas
    3. CWith double quotes
    4. DWith double dashes
    Show the answer

    Double quotes create a delimited identifier, which is treated as an identifier even when its text matches a keyword; single quotes instead delimit regular strings.

    Next → 2 / 10
  3. Question 3 of 10

    How is an apostrophe represented inside a regular SQL string constant?

    1. AAs a double-dash sequence
    2. BAs two adjacent single quotes
    3. CAs two adjacent double quotes
    4. DAs one unquoted apostrophe
    Show the answer

    A regular string uses single-quote delimiters, so an embedded single quote is doubled; double quotes belong to identifier syntax.

    Next → 3 / 10
  4. Question 4 of 10

    How does PostgreSQL treat a comment before syntax analysis?

    1. AIt treats the comment as the terminator for every following command
    2. BIt parses the comment as an identifier with no case folding
    3. CIt evaluates the comment as a string constant before the command
    4. DIt removes the comment and replaces it effectively with whitespace
    Show the answer

    Comments are not tokens and are effectively whitespace after removal; command termination remains the role of a semicolon or end of input.

    Next → 4 / 10
  5. Question 5 of 10

    What is the initial PostgreSQL type of a whole-number constant that fits in integer?

    1. Abigint
    2. Breal
    3. Cnumeric
    4. Dinteger
    Show the answer

    PostgreSQL starts a whole-number constant with `integer` when it fits, tries `bigint` next, and uses `numeric` only when it fits neither integer type.

    Next → 5 / 10
  6. Keep the ones you got wrong

    In the app, every question you miss comes back exactly when you’re about to forget it.

  7. Question 6 of 10

    Which token supplies a Boolean argument value in the documented PostgreSQL function-call examples?

    1. Atrue
    2. B"true"
    3. C-- true
    4. D'true'
    Show the answer

    The examples pass `true` and `false` as Boolean values; quoting changes the token into a string or identifier, while a double dash begins a comment.

    Next → 6 / 10
  8. Question 7 of 10

    Which literal form explicitly assigns the intended date type?

    1. A2030-01-15
    2. BDATE '2030-01-15'
    3. CDATE "2030-01-15"
    4. D'2030-01-15'
    Show the answer

    The `type 'string'` form assigns the named type to a simple literal; a quoted string alone leaves type resolution to context.

    Next → 7 / 10
  9. Question 8 of 10

    A query must refer to a column named select and another named SalesTotal, preserving both names exactly. Which select list satisfies both constraints?

    1. A"select", "SalesTotal"
    2. B"select", salestotal
    3. C'select', 'SalesTotal'
    4. Dselect, SalesTotal
    Show the answer

    Delimited identifiers make `select` an object name rather than a keyword and preserve the mixed case of `SalesTotal`; unquoted names are folded to lower case in PostgreSQL.

    Next → 8 / 10
  10. Question 9 of 10

    A value must contain the text Dianne's horse, use the regular SQL string form, and avoid PostgreSQL escape or dollar-quote extensions. Which expression meets all constraints?

    1. A'Dianne''s horse'
    2. B"Dianne's horse"
    3. C$$Dianne's horse$$
    4. DE'Dianne\'s horse'
    Show the answer

    The regular form doubles the embedded apostrophe inside single-quote delimiters; the `E` and dollar-quoted forms are PostgreSQL extensions.

    Next → 9 / 10
  11. Question 10 of 10

    An expression must state an exact numeric target type and use the SQL-conforming conversion syntax rather than a PostgreSQL-specific shorthand. Which form fits both requirements?

    1. A1.23
    2. BCAST (1.23 AS real)
    3. C1.23::numeric
    4. DCAST (1.23 AS numeric)
    Show the answer

    `CAST` explicitly requests the `numeric` target and conforms to SQL; the double-colon form is historical PostgreSQL syntax, and the bare literal relies on its initial typing and context.

    Next → 10 / 10
  12. You’ve finished this set

    That’s 10 questions on SQL Lexical Structure. In the app the ones you miss come back exactly when you’re about to forget them.

The whole course, on your phone

Lessons you can read, audio you can listen to on the way to work, and practice that remembers what you got wrong.