Help Center > > Developer Guide> SQL Reference> SQL Syntax> CREATE DIRECTORY

CREATE DIRECTORY

Updated at: Mar 13, 2020 GMT+08:00

Function

CREATE DIRECTORY creates a directory. The directory defines an alias for a path in the server file system and is used to store data files used by users. Users can read and write these files through the utl_file advanced package.

The read and write permissions for the directory can be granted to specified users to provide permission control for utl_file.

Precautions

  • Only users with the sysadmin permission can create a directory.
  • By default, the user who creates a directory has the read and write permissions for the directory.
  • The default owner of the directory is the user who creates it.
  • A directory cannot be created for the following paths:
    • The path contains special characters.
    • The path is a relative path.
    • The path is a symbolic link.
  • The following validity check is performed during directory creation:
    • Check whether the path exists in the OS. If it does not exist, a message is displayed, indicating the potential risks.
    • Check whether the database initial user omm has the R/W/X permissions for the OS path. If the user does not have all the permissions, a message is displayed, indicating the potential risks.
  • In a cluster, ensure that the path is the same on all the nodes. Otherwise, the path may fail to be found on some nodes when the directory is used.

Syntax

1
2
CREATE [OR REPLACE] DIRECTORY directory_name
AS 'path_name';

Parameter Description

  • directory_name

    Specifies name of a directory to be created.

    Value range: a string compliant with the identifier naming convention

  • path_name

    Specifies the OS path for which a directory is to be created.

    Value range: a valid OS path

Examples

1
2
-- Creates a directory.
CREATE OR REPLACE DIRECTORY  dir  as '/tmp/';

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel