Created
February 11, 2020 10:10
-
-
Save tharikaGitHub/4d3351a415d3aa3c5c311decc674c695 to your computer and use it in GitHub Desktop.
REG_LOG Table Cleanup 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
CREATE TABLE REG_LOG_IDS_TO_KEEP ( | |
REG_LOG_ID INTEGER, | |
REG_TENANT_ID INTEGER | |
); | |
INSERT INTO REG_LOG_IDS_TO_KEEP (REG_LOG_ID, REG_TENANT_ID) | |
SELECT MAX(REG_LOG_ID) AS REG_LOG_ID, REG_TENANT_ID FROM REG_LOG GROUP BY REG_PATH, REG_TENANT_ID; | |
DELETE FROM REG_LOG WHERE REG_LOG_ID NOT IN (SELECT REG_LOG_ID FROM REG_LOG_IDS_TO_KEEP); | |
DROP TABLE REG_LOG_IDS_TO_KEEP; | |
DELETE FROM REG_LOG WHERE REG_ACTION = 7; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment