CREATE DIRECTORY v16
Name
CREATE DIRECTORY
— Create an alias for a file system directory path.
Synopsis
Description
The CREATE DIRECTORY
command creates an alias for a file system directory pathname. You must be a database superuser to use this command.
When you specify the alias as the appropriate parameter to the programs of the UTL_FILE
package, the operating system files are created in or accessed from the directory corresponding to the alias.
Parameters
name
The directory alias name.
pathname
The fully qualified directory path represented by the alias name. The CREATE DIRECTORY
command doesn't create the operating system directory. The physical directory must be created independently using operating system commands.
Notes
The operating system user id enterprisedb
must have the appropriate read and write privileges on the directory if you want to use the UTL_FILE
package to create or read files using the directory.
The directory alias is stored in the pg_catalog.edb_dir
system catalog table.
Note
The edb_dir
table isn't compatible with Oracle databases.
You can also view the directory alias from the Oracle catalog views SYS.ALL_DIRECTORIES
and SYS.DBA_DIRECTORIES
. These views are compatible with Oracle databases.
Use the DROP DIRECTORY
command to delete the directory alias. Deleting a directory alias doesn't affect the corresponding physical file system directory. Delete the file system directory using operating system commands.
In a Linux system, the directory name separator is a forward slash (/)
.
In a Windows system, you can specify the directory name separator as a forward slash (/)
or two consecutive backslashes (\\)
.
Examples
Create an alias named empdir
for the directory /tmp/empdir
on Linux:
Create an alias named empdir
for the directory C:\TEMP\EMPDIR
on Windows:
View all of the directory aliases:
View the directory aliases using a view compatible with Oracle databases: