Purpose
This statement is used to create a directory object.
Privilege requirements
To create a directory object, you must have the
CREATE ANY DIRECTORYsystem privilege. For more information about OceanBase Database privileges, see Privilege classification in Oracle-compatible mode.To ensure the security of file operations, when creating a file directory object, you must set the system variable
secure_file_privto a specified secure directory. For more information, see secure_file_priv.
Syntax
CREATE [ OR REPLACE ] DIRECTORY directory AS 'path_name';
Parameters
Parameter |
Description |
|---|---|
| OR REPLACE | Specifies OR REPLACE to indicate that if the corresponding directory object already exists, the new file system path will replace the existing path definition. |
| directory | Specifies the name of the directory object to be created, with a maximum length of 30 bytes. |
| path_name | Specifies the file system path, which defines the absolute path name of the shared file system. The path name is case-sensitive.
NoticeOceanBase Database does not create a path on the file system for the user. When specifying |
Examples
Follow these steps to create a directory object.
Set the global secure path.
Notice
Due to security reasons, when setting the system variable
secure_file_priv, you can only execute the SQL statement to modify this global variable through a local Socket connection to the database. For more information, see secure_file_priv.Connect to OceanBase Database through a local Unix Socket. Example:
obclient -S /home/admin/test421/oceanbase/run/sql.sock -usys@oracle001 -p******Set the global secure path.
obclient [SYS]> SET GLOBAL secure_file_priv = "/usr/sqldump";
Log out.
Note
Since
secure_file_privis aGLOBALvariable, you need to execute\qto log out for the change to take effect.obclient [SYS]> \qReconnect to the database.
obclient -hxxx.xxx.xxx.xxx -P2881 -utest_user001@oracle001 -p******Create a directory object named
sql_file_dir.obclient [TEST_USER001]> CREATE OR REPLACE DIRECTORY sql_file_dir AS '/usr/sqldump';
