Last active
July 17, 2017 06:45
-
-
Save jazio/cdd80d161e99bce5033afdbf97beeaef to your computer and use it in GitHub Desktop.
Simulate mySQL commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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