UNDO is a non-standard, vendor-specific command that behaves like ROLLBACK: it discards all data modifications made since the current transaction began and releases any locks held. Some interactive SQL shells (IBM Informix, Teradata BTEQ, Firebird, older Sybase tools) accept UNDO or UNDO WORK as a shorthand for ROLLBACK. Because UNDO is not part of the SQL standard, most modern database engines (PostgreSQL, MySQL, SQL Server, Oracle, SQLite) do not recognise it; they require the portable ROLLBACK statement instead. Attempting to run UNDO in those systems raises a syntax error. Use UNDO only when you are certain the target client or DBMS supports it. Once a transaction has been committed, neither UNDO nor ROLLBACK can reverse it. For granular reversal inside a transaction, SAVEPOINT and ROLLBACK TO SAVEPOINT are preferred and portable.
IBM Informix SQL (early 1990s)
Both reverse uncommitted changes, but ROLLBACK is portable and defined by the SQL standard, while UNDO is a vendor-specific alias.
Most engines do not implement UNDO. Use ROLLBACK instead or consult your DBMS documentation for supported keywords.
No. Once COMMIT is executed, data changes are permanent. You would need point-in-time recovery techniques, such as backups or flashback features, to restore previous states.
Define a SAVEPOINT before the section you might cancel, then issue ROLLBACK TO SAVEPOINT savepoint_name; this is supported by all major databases.