Previous PageTable Of ContentsNext Page

3.3.12 CREATE DIRECTORY

Name

CREATE DIRECTORY -- create an alias for a file system directory path

Synopsis

CREATE DIRECTORY name AS ‘pathname

Description

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.

Parameters

name

The directory alias name.

pathname

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.

Notes

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 (\\).

Examples

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';

Previous PageTable Of ContentsNext Page