Purpose
You can use this statement to create a directory.
Required privileges
To create a directory, you must have the
CREATE ANY DIRECTORYsystem privilege. For more information about privileges in OceanBase Database, see Privilege types in Oracle-compatible mode.To ensure the security of file operations, you must set the system variable
secure_file_privto the specified security directory when you create a directory. For more information, see secure_file_priv.
Syntax
CREATE [ OR REPLACE ] DIRECTORY directory AS 'path_name';
Parameters
| Parameter | Description |
|---|---|
| OR REPLACE | After OR REPLACE is specified, if the specified directory name already exists, a new file system path replaces the original directory definition. |
| directory | The name of the directory to be created, which cannot exceed 30 bytes in length. |
| path_name | The absolute path where the shared file system is located. The path name is case-sensitive.
NoticeOceanBase Database does not create paths for users in the file system. Therefore, ensure that the path is real when you specify |
Examples
Perform the following steps to create a directory:
Set a global security path.
Notice
For security reasons, you can connect to the database only through a local socket to execute the SQL statement for setting
secure_file_priv. For more information, see secure_file_priv.Connect to OceanBase Database by using a local Unix socket. Here is an example:
obclient -S /home/admin/test421/oceanbase/run/sql.sock -usys@oracle001 -p******Set a global security path.
obclient [SYS]> SET GLOBAL secure_file_priv = "/usr/sqldump";
Log out of the database.
Note
secure_file_privis aGLOBALvariable. Therefore, you need to run\qto exit for the settings to take effect.obclient [SYS]> \qReconnect to the database.
obclient -hxxx.xxx.xxx.xxx -P2881 -utest_user001@oracle001 -p******Create a directory named
sql_file_dir.obclient [TEST_USER001]> CREATE OR REPLACE DIRECTORY sql_file_dir AS '/usr/sqldump';