Child pages
  • Production Database Protocol

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

After starting a connection to the database from the command-line you should ALWAYS run:

Code Block
languagesql
SET autocommit=0;

 

By default any changes you make to the database cannot be reverted because MySQL automatically commits all changes immediately. By setting autocommit=0 you can rollback any mistakes you make. If you make a mistake you can always undo your command with:

Code Block
languagesql
ROLLBACK;

...


Whenever you want to make changes you should use this construct:

Code Block
languagesql
START TRANSACTION;

...


(UPDATE, INSERT, etc.)

...


COMMIT;

...


If you make a mistake when you run your (UPDATE, INSERT, etc.) command you can use ROLLBACK to undo changes back to the START TRANSACTION statement.

...