Oracle9i SQL Reference Release 2 (9.2) Part Number A96540-02 |
|
|
View PDF |
Use the CREATE
DIRECTORY
statement to create a directory object. A directory object specifies an alias for a directory on the server's file system where external binary file LOBs (BFILE
s) and external table data are located. You can use directory names when referring to BFILE
s in your PL/SQL code and OCI calls, rather than hard coding the operating system path name, thereby providing greater file management flexibility.
All directories are created in a single namespace and are not owned by an individual's schema. You can secure access to the BFILE
s stored within the directory structure by granting object privileges on the directories to specific users.
See Also:
|
You must have CREATE
ANY
DIRECTORY
system privileges to create directories.
When you create a directory, you are automatically granted the READ
and WRITE
object privileges on the directory, and you can grant these privileges to other users and roles. The DBA can also grant these privileges to other users and roles.
WRITE
privileges on a directory are useful in connection with external tables. They let the grantee determine whether the external table agent can write a log file or a bad file to the directory.
You must also create a corresponding operating system directory for file storage. Your system or database administrator must ensure that the operating system directory has the correct read and write permissions for Oracle processes.
Privileges granted for the directory are created independently of the permissions defined for the operating system directory. Therefore, the two may or may not correspond exactly. For example, an error occurs if sample user hr
is granted READ
privilege on the directory schema object but the corresponding operating system directory does not have READ
permission defined for Oracle processes.
create_directory::=
Specify OR
REPLACE
to re-create the directory database object if it already exists. You can use this clause to change the definition of an existing directory without dropping, re-creating, and regranting database object privileges previously granted on the directory.
Users who had previously been granted privileges on a redefined directory can still access the directory without being regranted the privileges.
See Also:
DROP DIRECTORY for information on removing a directory from the database |
Specify the name of the directory object to be created. The maximum length of directory
is 30 bytes. You cannot qualify a directory object with a schema name.
Specify the full path name of the operating system directory on the server where the files are located. The single quotes are required, with the result that the path name is case sensitive.
The following statement creates a directory database object that points to a directory on the server:
CREATE DIRECTORY admin AS 'oracle/admin';
The following statement redefines directory database object bfile_dir
to enable access to BFILE
s stored in the operating system directory /private1/lob/files
:
CREATE OR REPLACE DIRECTORY bfile_dir AS '/private1/LOB/files';