SQL Flashcards
relational database
represents a collection of related (two-dimensional) tables. Each of the tables are similar to an Excel spreadsheet, with a fixed number of named columns (the attributes or properties of the table) and any number of rows of data.
SQL
structured query language
in SQL columns represent x?
properties
in SQL rows represent x?
instances
how to select all columns of data in a table?
“dumping all the data at once”
SELECT *
FROM table_name;
how to select several columns in a database?
by separating them with a comma:
SELECT title, director FROM movies;
conditional word for operations with constraints
WHERE e.g.: SELECT column, another_column, … FROM mytable WHERE condition AND/OR another_condition AND/OR …;
operator for: Number is within range of two values (inclusive)
BETWEEN … AND …
e.g.:
col_name BETWEEN 1.5 AND 10.5
operator for: Number is not within range of two values (inclusive)
NOT BETWEEN … AND …
e.g.:
col_name NOT BETWEEN 1 AND 10
operator for: number exists in a list
IN (…)
e.g.:
col_name IN (2, 4, 6)
operator for: number does not exist in a list
NOT IN (…)
e.g.:
col_name NOT IN (1, 3, 5)
query capitalization mandatory?
NO. Just a convention to help distinguish from column and table names
operator: Case sensitive exact string comparison
=
operator: Case sensitive exact string inequality comparison
!= or <>
operator: Case insensitive exact string comparison
LIKE