CREATE DIRECTORY -- create an alias for a file system directory path
CREATE DIRECTORY name AS ‘pathname’
The CREATE DIRECTORY command creates an alias for a file system directory pathname. When the alias is specified 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 given alias. See Section 0 for information on the UTL_FILE package.
The directory alias name.
The fully-qualified directory path represented by the alias name. The CREATE DIRECTORY command does not create the operating system directory. The physical directory must be created independently using the appropriate operating system commands.
The operating system user id, enterprisedb, must have the appropriate read and/or write privileges on the directory if the UTL_FILE package is to be used to create and/or read files using the directory.
A directory alias must be deleted directly from the pg_catalog.edb_dir system catalog table if it is desired to remove the directory alias. This operation must be performed by a superuser. Note that edb_dir is not an Oracle compatible table.
When a directory alias is deleted, the corresponding physical file system directory is not affected. The file system directory must be deleted using the appropriate operating system commands.
In a Linux system, the directory name separator is a forward slash (/).
In a Windows system, the directory name separator can be specified as a forward slash (/) or two consecutive backslashes (\\).
Create an alias named, empdir, for directory, /tmp/empdir, on Linux:
CREATE DIRECTORY empdir AS '/tmp/empdir';
Create an alias named, empdir, for directory, C:\TEMP\EMPDIR, on Windows:
CREATE DIRECTORY empdir AS 'C:/TEMP/EMPDIR';
View all of the directory aliases:
SELECT * FROM pg_catalog.edb_dir; dirname | dirpath ---------+---------------- empdir | C:/TEMP/EMPDIR (1 row)
Remove directory, empdir:
DELETE FROM pg_catalog.edb_dir WHERE dirname = 'empdir';
Copyright © 2013 EnterpriseDB Corporation. All rights reserved.