SQL

Overview

The Structured Query Language (SQL) is the most commonly used language for interacting with relational data models. Some standard syntactic features include:

Basic Types

The SQL standard supports a variety of built-in types including:

Common extensions include:

Strings

String literals are declared between two apostrophes (i.e. '). An apostrophe within a string can be escaped using two consecutive apostrophes (i.e. '').

A number of functions and operators are defined by the SQL standard to manipulate strings. These include:

' ESCAPE ''`
Reference: silberschatz

ENDANKI
Basic
What is the result of the following query?

SELECT 1 + NULL;

Back: NULL
Reference: silberschatz

ENDANKI
Basic
What is the result of the following query?

SELECT 1 < NULL;

Back: UNKNOWN
Reference: silberschatz

ENDANKI
Basic
What truth values are supported in SQL?
Back: TRUE, FALSE, and UNKNOWN.
Reference: silberschatz

ENDANKI
Basic
Why does SQL support the UNKNOWN truth value?
Back: NULL is used to represent uknown values.
Reference: silberschatz

ENDANKI
Basic
How do NULL values compare in a WHERE clause?
Back: As distinct.
Reference: silberschatz

ENDANKI
Basic
How do NULL values compare in a SELECT DISTINCT clause?
Back: As equal.
Reference: silberschatz

ENDANKI
Basic
How do NULL values compare in a UNION?
Back: As equal.
Reference: silberschatz

ENDANKI
Basic
What name is given to the SQL construct (v1,,vn)?
Back: A row constructor.
Reference: silberschatz

ENDANKI
Basic
SQL row constructors are used to create what kind of mathematical objects?
Back: n-tuples.
Reference: silberschatz

ENDANKI
Basic
How is the following SQL fragment rewritten using row constructors?

WHERE X1 = Y1 AND X2 = Y2

Back:

WHERE (X1, X2) = (Y1, Y2)

Reference: silberschatz

ENDANKI
Basic
How is the following SQL fragment rewritten using row constructors?

WHERE X1 = Y1 OR X2 = Y2

Back: N/A. The OR construct is not translatable.
Reference: silberschatz

ENDANKI
Basic
How is the following SQL fragment rewritten without row constructors?

WHERE (X1, X2) = (Y1, Y2)

Back:

WHERE X1 = Y1 AND X2 = Y2

Reference: silberschatz

ENDANKI
Basic
How is the following SQL fragment rewritten without row constructors?

WHERE (X1, X2) < (Y1, Y2)

Back:

WHERE X1 < Y1 AND X2 < Y2

Reference: silberschatz

END%%

Powered by Forestry.md