Create Directory in Autonomous Database

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 for more information.

Note

  • CREATE DIRECTORY creates the database directory object in the database and also creates the file system directory. For example the directory path could be:
    /u03/dbfs/7C149E35BB1000A45FD/data/stage
  • 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_DIR directory, use the following command to list all files:

    SELECT * FROM DBMS_CLOUD.list_files('ROOT_DIR');

    To run DBMS_CLOUD.LIST_FILES with 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 in the file system allocated for the directories you create and their contents is part of your storage allocation. See Database Dashboard Overview to view the total space allocated.