SQL Flashcards
✅Delete (2) vs (2) Truncate
Delete
1 - slower
2 - you can rollback data Truncate
Truncate
1 - faster
2 - rollback not possible
✅Explain each type of Join
(INNER) JOIN: Returns records that have matching values in both tables
LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table
RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table
FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table
✅ char vs varchar2
char
1 - fixed length,
eg char(10) stores 10 characters, no more no less
varchar2
1 flexible length
eg varchar2(10) stores between 1 and 10 characters
✅ Constrains
Not null
unique
primary key
foreing key
check
default
index
✅ Data Integrity
Refers to the accuracy and consistency of data
✅ Subsets of SQL
DDL - Data Definition Language
DML - Data Manipulation Language
DCL - Data Control Language
TCL - Transaction Control Language
Triggers (6)?
Before insert
After insert
Before update
After update
Before delete
After delete
✅ Cross Join
Produces cartesian product of two tables
✅ List some Aggregate Functions (6)
1 - AVG
2 - COUNT
3- SUM
4 - MAX
5 - MIN
✅ Different between Scalar Functions and Aggregate Functions
Aggregate Functions are based on the columns
Scalar Functions are based on the input value
✅ Merge statement
Syncrhonize two tables by inserting, updating or deleting rwos based on differences found
✅ What is a SQL Clause?
Conditions to limit the result, like WHERE or HAVING
✅ List the ways in which Dyamic SQL can be executed?
1- sp_executesql
2- EXEC
✅ How to select unieque records from a table?
DISTINCT
✅ What function would you use to fetch first the 5 characters of a string?
SUBSTRING