Created
April 20, 2022 07:35
-
-
Save loiclefevre/a371f6c5f83badd2860c644bfd15897b to your computer and use it in GitHub Desktop.
Recyclebin and recovering dropped table
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 very_important_data ( | |
salary_wanted NUMBER CHECK (salary_wanted > 1000000) | |
); | |
INSERT INTO very_important_data (salary_wanted) VALUES( 2000000 ); | |
COMMIT; | |
DROP TABLE very_important_data; | |
Table VERY_IMPORTANT_DATA dropped. -- Ouch my data! | |
-- However... | |
SELECT object_name, operation, type, can_undrop | |
FROM user_recyclebin | |
WHERE original_name = 'VERY_IMPORTANT_DATA'; | |
OBJECT_NAME OPERATION TYPE CAN_UNDROP | |
------------------------------- ---------- ------ ----------- | |
BIN$3RDQcUKRKKzgU1sQAAoyZw==$0 DROP TABLE YES | |
-- Even better... | |
SELECT * FROM "BIN$3RDQcUKRKKzgU1sQAAoyZw==$0"; | |
SALARY_WANTED | |
-------------- | |
2000000 | |
FLASHBACK TABLE very_important_data TO BEFORE DROP | |
RENAME TO very_lucky_data; | |
Flashback succeeded. | |
SELECT * FROM very_lucky_data; -- back on track! | |
SALARY_WANTED | |
-------------- | |
2000000 | |
DROP TABLE very_lucky_data PURGE; -- to bypass the recyclebin | |
-- saving storage... | |
PURGE TABLE very_lucky_data; -- to clean just the table | |
PURGE recyclebin; -- to clean the whole recyclebin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment