Last active
January 4, 2018 21:38
-
-
Save brendomaciel/3bbbe0ba979fb64cea4cddf9bb2e5562 to your computer and use it in GitHub Desktop.
Comandos úteis para servidores MySQL.
This file contains 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
SET @@session.foreign_key_checks = 0; | |
SET @@global.connect_timeout = 200; | |
SET @@session.max_allowed_packet = 16M; | |
SET @@session.wait_timeout = 200; | |
SET @@session.interactive_timeout = 200; | |
SET @@session.net_read_timeout = 200; | |
SET @@session.net_write_timeout = 200; | |
# Gerar SQL para limpar todas as tabelas do banco | |
SELECT CONCAT('TRUNCATE TABLE `',table_schema,'`.`',TABLE_NAME, '`;') | |
FROM INFORMATION_SCHEMA.TABLES | |
WHERE table_schema IN('database_name'); | |
# Trava a linha para operações de escrita | |
SELECT * | |
FROM parent | |
WHERE key = '' | |
LOCK IN SHARE MODE; | |
# Trava a linha para operações de leitura e escrita | |
SELECT counter_field | |
FROM child_codes | |
FOR UPDATE; | |
UPDATE child_codes | |
SET counter_field = counter_field + 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment