How to create a directory and grant permissions in Oracle?
To create a DIRECTORY and grant permissions to it in an Oracle database, follow these steps:
- Firstly, log in to the Oracle database as a user with the CREATE ANY DIRECTORY system privilege.
- Create a DIRECTORY using the following SQL statement and specify the directory path that needs to be accessed.
CREATE OR REPLACE DIRECTORY my_dir AS '/path/to/directory';
- Grant access permission to the newly created DIRECTORY using the following SQL statement:
GRANT READ, WRITE ON DIRECTORY my_dir TO your_user;
Please replace your_user with the user who needs access to the DIRECTORY.
- Finally, make sure that the newly created DIRECTORY has been properly authorized and is accessible. You can use the following SQL statement to query the users who have been granted permission to access the DIRECTORY:
SELECT grantee, privilege
FROM dba_tab_privs
WHERE table_name = 'MY_DIR';
After completing the above steps, you have successfully created a DIRECTORY and granted it access permissions. You can now use this DIRECTORY in the database to access the specified directory path.