Week 8 Flashcards
What SQL command allows you to enter data into a table? What is the syntax for this command?
INSERT INTO VALUES (value1, value2, …, valuen)
Each value corresponds to a column for that table.
What SQL command allows you to modify data in a table? What is the syntax for this command?
UPDATE
SET
WHERE
What happens if WHERE is not specific for UPDATE?
All values for columns indicated in SET would be changes to the expression entered
How can you restore table contents before COMMIT has been executed?
Enter the ROLLBACK; command
Which data manipulation commands can ROLLBACK revert?
- Commands that add table rows
- Commands that modify table rows
- Commands that delete table rows
What SQL command allows you to delete data in a table? What is the syntax for this command?
DELETE FROM
WHERE
What happens if WHERE is not specific for DELETE?
All rows in specified table will be deleted
What SQL commands allows you to copy data in a table into a new table? What is the syntax for this command?
- Create new table with attributes to be copied using
CREATE
NOTE: Attributes in copied table DO NOT need to be the same as original table. BUT tuple of attributes need to be specified in next step if not same.
- Extract and insert data from original table into new table using INSERT INTO command.
INSERT INTO or
SELECT
FROM
What is the oracle method of copying data into a new table?
CREATE TABLE AS
SELECT
FROM
What SQL command allows you to add designations to attributes in an existing table? What is the syntax for this command? What designations can you allocate?
ALTER TABLE
ADD (column name);
Designations include:
PRIMARY KEY
FOREIGN KEY
UNIQUE
What is a transaction?
It is a logical unit of work that must be ENTIRELY completed OR aborted.
If only one portion of the transaction is successful and the remainder is unsucessful, the WHOLE transaction is unsucessful
If you query data from a table in a database, is this considered a transaction?
Yes, since it accesses the database.
What are properties of each individual transaction?
What do they mean?
- Atomicity: Transaction is a single logical unit of work
- Consistency: Database must maintain a consistent state
- Isolation: Data in use by one transaction cannot be accessed until the first is complete.
- Durability: Transactions cannot be undone or lost
What do DBMS use to keep track of all transactions that update the database?
A transaction log
What data does a transaction log contain?
• A record for the beginning of the transaction.
• For each transaction component (SQL statement):
– The type of operation being performed (INSERT, UPDATE, DELETE).
– The names of the objects affected by the transaction (the name of the table).
– The “before” and “after” values for the fields being updated.
– Pointers to the previous and next transaction log entries for the same transaction.
• The ending (COMMIT) of the transaction.