SQL Flashcards
What does CRUD stand for?
Create
Read
Update
Delete
Example of Create in SQL?
INSERT INTO TableName (ColName1, ColName2)
VALUES (value1, value2)
Example of Read in SQL?
SELECT column name
FROM table name
WHERE Condition is true
AND another Condition
Example of Update in SQL?
UPDATE table name
SET column name = new value 1
WHERE column name = some value
Example of Delete in SQL?
DELETE FROM table name
WHERE column name = some value
Example of INNER JOIN in SQL?
SELECT TableName1.ColName1 TableName2.ColName2
FROM TableName1 JOIN TableName2 ON TableName1.PK = TableName2.FK
What are the variations of the use of LIKE in SQL?
LIKE ‘Ber%’ (selects items with “ber” at the start).
LIKE ‘%co%’ (selects all customers with a city containing the pattern “co”)
What does an NESTED SELECT look like in SQL?
SELECT ColumnName1
FROM TableName1
WHERE ColumnName1 =/IN (SELECT ColumnName2
FROM TableName2
WHERE ColumnName2 = someValue)
IN is used when more than one result will return.
What are transactions?
BEGIN TRANSACTIONS;
They have to happen all at once as if there is a power cut, the data will be lost.
What is the ACID principle?
Atomicity - all or nothing.
Consistent - all of the database rules must be followed.
Isolation - order of execution doesn’t matter.
Durability - once committed, the transaction must stay committed.
What is record locking?
When a record is locked so it won’t get overwritten.