Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

rollback

Undo database changes

Syntax

rollback(conn)

Description

rollback(conn) reverses changes made to a database using datainsert, fastinsert, insert, or update via the database connection conn. The rollback function reverses all changes made since the last COMMIT or ROLLBACK operation. To use rollback, the AutoCommit flag for conn must be off.

Note

If the database engine is not InnoDB, rollback does not roll back data in MySQL® databases.

Examples

  1. Ensure that the AutoCommit flag for connection conn is off by running:

    get(conn,'AutoCommit')
    ans =
    	off
    
  2. Insert data contained in exdata into the columns DEPTNO, DNAME, and LOC, in the table DEPT, for the data source conn.

    datainsert(conn,'DEPT',...
    {'DEPTNO';'DNAME';'LOC'},exdata)
    
  3. Roll back the data exdata that you inserted into the database by running:

    rollback(conn)
    

    The database contains the original data present before running datainsert.

Tips

For ODBC connections, you can use the rollback function with the native ODBC interface. For details, see database.

Introduced before R2006a

Was this topic helpful?