What is SQL used for?
SQL defines relational tables and retrieves information from the data they contain.
Study 3 SQL Fundamentals with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is SQL used for?
SQL defines relational tables and retrieves information from the data they contain.
What are the basic parts of a relational table?
A table has named columns and rows. Each column has a data type suited to the values it stores.
What does a primary key do?
A primary key uniquely identifies each row. It can consist of one column or several columns.
What does the NOT NULL constraint require?
NOT NULL requires a column to have a value; it prevents missing values in that column.
What does the UNIQUE constraint prevent?
UNIQUE prevents duplicate values in the constrained column or columns.
How does a CHECK constraint protect data?
CHECK enforces a condition on values. For example, CHECK (price >= 0) prevents negative prices.
What do SELECT and FROM specify in a basic query?
SELECT names the columns to return, and FROM names the table to read. Use * to request all columns.
What does WHERE do in a query?
WHERE keeps only rows whose condition is true, such as rows with price < 25 AND in_stock > 0.
How should a query test for a NULL value?
NULL represents a missing or unknown value; it is not the same as zero or an empty string. Test it with IS NULL or IS NOT NULL.
What does the IN operator check?
IN matches a value against a list of alternatives, such as category IN ('Books', 'Games').
How does ORDER BY affect query results?
ORDER BY requests a result order. ASC is the default; DESC sorts in descending order. Without ORDER BY, row order is not guaranteed.
What does LIMIT do, and why pair it with ORDER BY?
LIMIT restricts the number of returned rows in many databases. Pair it with ORDER BY for a predictable selection.