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
-- A simple script that allows you to perform update and delete operations with optional where clause but mainly giving | |
-- you the flexibilty of doing so across multiple db, tables and columns | |
do $$ | |
declare | |
selectrow record; | |
begin | |
for selectrow in | |
select | |
'DELETE FROM '|| t.mytable || ' WHERE ' || t.mytable ||'.sampledate > ''12-31-2018''' as script |
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
-- Select your database | |
USE sample_database; | |
/* You might need to run this if MySQL says that the below function is non-determininstic (although I've added DETERMINSTIC keyword in it) */ | |
-- SET GLOBAL log_bin_trust_function_creators = 1; | |
DELIMITER $$ | |
DROP FUNCTION IF EXISTS splitString $$ | |
-- Function splitString that returns a substring based on a certain delimiter's position | |
CREATE FUNCTION splitString ( | |
x VARCHAR(255), | |
delim VARCHAR(12), |