Oracle SQL study materials
Oracle SQL study resources

Oracle SQL: Managing Data with DML

Oracle SQL · Work through your exam, one topic at a time.

All guide sections

Managing Data with DML

The statements

INSERT adds rows, either with a VALUES list, with & substitution variables, or by copying from a subquery (the column count must match). UPDATE changes existing rows and may take a subquery in SET or WHERE. DELETE removes rows; with no WHERE it removes all of them but still leaves the table structure. MERGE performs conditional insert-or-update in a single pass.

Transactions

DML opens a transaction. COMMIT makes changes permanent, ROLLBACK undoes everything since the last commit, and SAVEPOINT marks an intermediate point for partial rollback (ROLLBACK TO sp). Oracle provides read consistency: other sessions never see your uncommitted changes, and you never see theirs.

Traps

An UPDATE or DELETE without WHERE affects every row - the single most common exam error. Any DDL statement (CREATE, ALTER, DROP, TRUNCATE) issues an implicit commit, so it cannot be rolled back. DELETE is DML, generates redo and rollback, and can be undone; TRUNCATE is DDL and cannot. Rollback cannot recover data that was already committed. WITH CHECK OPTION prevents inserting rows a view could not later display. A failed statement only rolls back that statement.

Worked example

UPDATE employees SET salary = salary * 1.10 WHERE department_id = 80; The WHERE restricts the raise to one department; omitting it would raise everyone's salary, and a rollback would recover it only if no DDL or COMMIT intervened.