SQL Flashcards
What are subtypes/sublanguages of SQL?
- DDL, DML, DQL, DCL TCL
What is DDL? What are the keywords?
- It stands for Data Definition Language
- The keywords are CREATE, ALTER, DROP, TRUNCATE
What is DML? What are the keywords?
- DML stands for Data Manipulation Language
- The keywords are INSERT, UPDATE, DELETE
What is DCL? What are the keywords?
- DCL stands for Data Control Language
- The keywords are GRANT and REVOKE
What is DQL? What are the keywords?
- DQL stands for Data Query Language
- The keyword with DQL is SELECT
What is TCL? What are the keywords?
- TCL stands for Transaction Control Language.
- The keywords are COMMIT, ROLLBACK, SAVEPOINT
What is a Constraint? Give a few examples.
- Constraints are rules used to limit the type of data that can go into a table.
Most used constraints include:
- NOT NULL
- UNIQUE
- PRIMARY KEY
- FOREIGN KEY
- CHECK
- DEFAULT
What are the different relationships in SQL?
- One-to-one - both tables can have only one record on either side of the relationship.
- One-to-many - one table can only have one record on its side of the relationship while
others can have many records of the relationship - Many-to-many - both sides can have many records on either side of the relationship.
What are the different types of Joins?
- Inner Join - Returns data that occurs in both tables, only where there is a match in both tables.
- Left Join - Returns the data that occurs in the left table and the values that matched records in the right table.
- Right Join - Returns the data from the right table and the matching data from the left table.
- Full Outer Join - Returns all records from both tables and matches them when
possible. - Self Join - Regular join where you join a table with itself.
- Cross Join - Produces a result set in which the number of rows in the first table multiplied by the number of rows in the second table if no WHERE clause is used
along with CROSS JOIN. This kind of result is called a Cartesian Product.
What are the set operators?
Set operators combine the results of two component queries into a single result.
Queries containing set operators are called compound queries.
- UNION ALL
- INTERSECT
- MINUS
What are the Transaction Properties? (ACID)
- Atomicity.
- Consistency.
- Isolation.
- Durability.
What is Atomicity?
- Atomicity - each transaction is all or nothing, if any part of the transaction fails the
whole of it fails, and then the database is rolled back to its last consistent state.
What is Consistency?
- Consistency - ensures that any transaction will bring the database from one valid state to another.
What is Isolation?
One transaction has
nothing to do with any of the others.
What is Durability?
- Durability - ensures that once a transaction has been committed, it will remain committed even in the event of power loss, crashes, or errors.