Advanced SQL Flashcards
Set
each table in a database or the result of a query
Empty set
query that returns no results
Member
row within a set
3 common set operators
- Intersection (INTERSECT)
- Difference (EXCEPT)
- Union
How to join tables?
with ON or USING
Embedded Select is also called
Derived table, cannot use order by, requires an alias
What is a correlated sub query?
Sub query that references a parent column
What types of fields can you join on?
Character, number or dates
What is a row subquery?
embedded select that returns more than 1 column and 0-1 rows
What is a table subquery?
returns 1 or more columns and 0 or more rows
What is a scalar subquery?
returns 1 column and 0-1 rows
What are the special predicates for sub queries?
IN (membership), ALL/ANY/SOME (quantified), EXISTS (existance)
How would you use a quantified predicate?
WHERE expression (=, , etc) [ANY, ALL, SOME] (subquery)
What are the SQL aggregate functions?
MIN, MAX, AVG, SUM, COUNT, COUNT distinct
Do aggregate functions ignore NULL values?
Yes except for COUNT(*)
What will an aggregate function return if all values are NULL?
NULL
T/F: You can embed one aggregate function with another
FALSE
T/F: you can use an aggregate function in a WHERE clause
TRUE, if you use the function in a subquery
How do you update a record?
UPDATE table_name
SET column_name = value
WHERE condition
How do you insert a record?
INSERT INTO table_name
(column names)
VALUES (values list)
How do you delete a record?
DELETE FROM table_name WHERE exp (where is optional)