Skip to content

Instantly share code, notes, and snippets.

@jazio
Last active July 17, 2017 06:45
Show Gist options
  • Save jazio/cdd80d161e99bce5033afdbf97beeaef to your computer and use it in GitHub Desktop.
Save jazio/cdd80d161e99bce5033afdbf97beeaef to your computer and use it in GitHub Desktop.
Simulate mySQL commands
# Simulate a deletion from database;
mysql> SELECT entity_id, language FROM field_data_body where language = 'und' AND entity_id IN (SELECT entity_id from field_data_body where language='en');
156 rows in set (0.05 sec)
# Need to delete 156 items but unsure if is a good idea
mysql> START TRANSACTION;
# Perform risky operation
mysql> DELETE FROM field_data_body WHERE language='und' AND entity_id IN (SELECT entity_id from (SELECT entity_id from field_data_body where language ='en') x);
mysql> SELECT entity_id, language FROM field_data_body where language = 'und' AND entity_id IN (SELECT entity_id from field_data_body where language='en');
0 rows in set (0.05 sec)
# Now, rollback will rollback changes. The opposite is COMMIT, when changes are commited and transaction is closed.
mysql> ROLLBACK;
mysql> SELECT entity_id, language FROM field_data_body where language = 'und' AND entity_id IN (SELECT entity_id from field_data_body where language='en');
156 rows in set (0.05 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment