Create a Directory
To create directories use the database CREATE
DIRECTORY command. Using CREATE DIRECTORY you
specify the path as a relative path for the new directory.
CREATE DIRECTORY creates the database directory
object and also creates the file system directory if it does not already
exist. If the file system directory exists then CREATE
DIRECTORY only creates the database directory object. For
example, the following command creates the database directory named
staging and creates the file system directory
stage:
CREATE DIRECTORY staging AS 'stage';You can also create subdirectories. For example, the following
command creates the database directory object
sales_staging and the file system directory
stage/sales:
CREATE DIRECTORY sales_staging AS 'stage/sales';When you create subdirectories you do not have to create the initial
file system directory. For example, in the previous example if the directory
stage does not exist then the CREATE
DIRECTORY command creates both directories
stage and stage/sales.
To add a directory, you must have the CREATE ANY
DIRECTORY system privilege. The ADMIN user is granted the
CREATE ANY DIRECTORY system privilege. The ADMIN user can grant CREATE
ANY DIRECTORY system privilege to other users.
See CREATE DIRECTORY in Oracle Database 19c SQL Language Reference or Oracle Database 26ai SQL Language Reference for more information.
Note:
-
CREATE DIRECTORYcreates the database directory object in the Autonomous AI Database and also creates the file system directory. -
You can create a directory in the root file system to see all the files with the following commands:
CREATE OR REPLACE DIRECTORY ROOT_DIR AS '';After you create the
ROOT_DIRdirectory, use the following command to list all files:SELECT * FROM DBMS_CLOUD.list_files('ROOT_DIR');To run
DBMS_CLOUD.LIST_FILESwith a user other than ADMIN you need to grant read privileges on the directory to that user. See LIST_FILES Function for more information. -
Space used by the directories you create and their contents is part of your database's data storage allocation.
Related Topics