Last active
June 14, 2018 12:05
-
-
Save belenaj/e91f8a81041d2713e34d11792c097b92 to your computer and use it in GitHub Desktop.
Dynamic SQL statement to replace the path of one or more Oracle Directories || #directory #oracle #sql
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 'DROP TABLE ' || TABLE_NAME || ';' | |
FROM USER_TABLES u | |
WHERE TABLE_NAME LIKE '%%' | |
ORDER BY 1 |
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
-- https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_5007.htm | |
-- Specify OR REPLACE to re-create the directory database object if it already exists. | |
-- You can use this clause to change the definition of an existing directory without dropping, | |
-- re-creating, and regranting database object privileges previously granted on the directory. | |
-- Users who had previously been granted privileges on a redefined directory can still access | |
-- the directory without being regranted the privileges. | |
SELECT | |
'CREATE OR REPLACE DIRECTORY ' || directory_name || ' AS ' || '''' || | |
REPLACE(directory_path, '/old', '/new') || '''' || ';' AS sqlstmt, | |
directory_name, | |
directory_path, | |
REPLACE(directory_path, '/old', '/new') AS replaced | |
FROM dba_directories | |
WHERE directory_name IN () |
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
. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment