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
| SELECT * FROM mysql.time_zone_name; | |
| SET GLOBAL time_zone = 'America/Sao_Paulo'; | |
| SELECT @@global.time_zone; |
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
| git rebase -i <hash do commit>~ | |
| git push -f |
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
| // Where String.prototype could be replaced | |
| Object.getOwnPropertyNames(String.prototype) |
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
| USE sakila; | |
| SELECT | |
| CONCAT(tbl_actor.last_name, | |
| ' ', | |
| tbl_actor.first_name) AS actor_name, | |
| tbl_film.title AS movie, | |
| ROW_NUMBER() OVER(PARTITION BY CONCAT(tbl_actor.last_name, | |
| ' ', | |
| tbl_actor.first_name)) AS total_movies |
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
| DROP TRIGGER IF EXISTS sakila.bf_insert_actor; | |
| DELIMITER $$ | |
| CREATE TRIGGER bf_insert_actor | |
| BEFORE INSERT ON sakila.actor | |
| FOR EACH ROW | |
| BEGIN | |
| IF NEW.actor_id IS NOT NULL THEN | |
| SET NEW.actor_id = null; |
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
| SELECT * FROM sakila.customer; | |
| SELECT | |
| (CASE | |
| WHEN active = 1 THEN 'ATIVO' | |
| ELSE 'INATIVO' | |
| END) AS user_active, | |
| CONCAT(first_name, ' ', last_name) AS full_name, | |
| YEAR(create_date) AS joined_at | |
| FROM |
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
| SELECT | |
| new_name, | |
| last_name, | |
| CONCAT(new_name, ' ', last_name) AS full_name | |
| FROM | |
| (SELECT | |
| (CASE | |
| WHEN first_name = 'NICK' THEN 'LINK' | |
| ELSE first_name | |
| END) AS new_name, |
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
| -- CREATE A TABLE BASED ON ANOTHER | |
| CREATE DATABASE people_by_name; | |
| CREATE TABLE people_by_name.people_with_p | |
| AS SELECT * FROM main_db.people WHERE first_name LIKE 'p%'; |