CREATE DIRECTORY
CREATE DIRECTORY#
Syntax#
Prerequisites#
Only the SYS user and users having the CREATE ANY DIRECTORY system privilege can execute this statement.
Description#
The fact that stored procedures are able to manipulate files means that it is possible to use SQL to read from and write to text files in the host's file system. This feature makes it possible to perform a wide variety of tasks, including leaving messages in files about the execution of stored procedures, writing reports and query results in files, and inserting data read from files into database tables.
The CREATE DIRECTORY statement is used to create a database object that corresponds to a directory that contains files that are manipulated by stored procedures in this way.
The owner of a DIRECTORY object created using the CREATE DIRECTORY statement is always the SYS user. The user who actually created the DIRECTORY object is only granted read and write privileges, including the WITH GRANT OPTION, for the object.
The CREATE DIRECTORY statement records directory data in the SYS_DIRECTORIES_ meta table, but does not actually create the new directory in the file system. Therefore, the user must explicitly create the directory in the actual file system.
OR REPLACE#
This option allows an existing DIRECTORY object to be replaced when a new DIRECTORY object is created with the same name. Note that the actual directory in the file system is not deleted.
directory_name#
This is used to specify the name of the database object representing the directory. Refer to "Rules for Object Names" for more information on specifying names
path_name#
This is used to specify the absolute path of the directory in the file system as a character string.
Examples#
<Query> Create a directory object named alti_dir1 in the folder /home/altibase/altibase_home/psm_msg.
iSQL> create directory alti_dir1 as '/home/altibase/altibase_home/psm_msg';
Create success.
<Query> > Create a directory object named alti_dir1 in the folder /home/altibase/altibase_home/psm_result. If a DIRECTORY object named alti_dir1 already exists in the database, replace it with this new one.
iSQL> create or replace directory alti_dir1 as '/home/altibase/altibase_home/psm_result';
Create success.