SQL Flashcards
What is the Having and Group By clauses for?
To perform aggregate calculation and filter results on specific conditions.
What is the difference between an inner and outer join?
Inner only returns matching rows of the two tables in a join, outer join return all the unmatched rows from either the left, right or both tables in the join.
What two sql functions handle null datasets?
Coalesce() and NVL()
What does the coalesce function do?
Takes two or more expressions and returns the first expression that is not-null from the list of expressions.
What is the difference between BETWEEN and IN operators in SQL?
Between is for a range of values, IN specifies multiple possible values
What is a correlated subquery?
A subquery that uses data from the containing query.
What are the database Constraints?
- DEFAULT
- UNIQUE
- NOT NULL
- PRIMARY KEY
- FOREIGN KEY
What is a foreign key?
A database enforced link between tables.
What is the difference between INTERSECT and UNION?
INTERSECT return rows that are common to both queries, UNION returns all distinct rows
What are some aggregate functions?
- MIN()
- COUNT()
- FIRST()
- LAST()
What are some scalar functions?
- UCASE()
- ROUND()
- NOW()
What is the difference between UNION and UNION ALL
UNION is distinct rows, UNION ALL allows duplicates
What is the difference between a clustered and non-clustered index?
Database keeps the data in the same order as the keys in the clustered index.
What are the 4 relationships in SQL?
- One-to-One
- One-to-Many
- Many-to-Many
- Self-reference