0% found this document useful (0 votes)
88 views2 pages

Create Directory in Oracle

Directories must be created in Oracle to allow external tables to access files outside the database. Directories are shown in dba_directories and all_directories views and read/write privileges can be granted on them. An example demonstrates creating a directory called 'dir_temp' pointing to a local folder and using utl_file to write lines of text to a file within that directory.

Uploaded by

carlosagb
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views2 pages

Create Directory in Oracle

Directories must be created in Oracle to allow external tables to access files outside the database. Directories are shown in dba_directories and all_directories views and read/write privileges can be granted on them. An example demonstrates creating a directory called 'dir_temp' pointing to a local folder and using utl_file to write lines of text to a file within that directory.

Uploaded by

carlosagb
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Create directory in Oracle

create or replace directory foo_dir as '/tmp';


Directories must be created if external tables are used.
Created directories are shown in either dba_directories or all_directories. There is no
user_directories.

Privileges
When a «directory» has been created, the read and write object privileges can be granted
on it:
create directory some_dir;
grant read, write on directory some_dir to micky_mouse;

An example
The following example shows how create directory and utl_file can be used to write text
into a file:
create or replace directory dir_temp as 'c:\temp';

declare
f utl_file.file_type;
begin
f := utl_file.fopen('DIR_TEMP', 'something.txt', 'w');
utl_file.put_line(f, 'line one: some text');
utl_file.put_line(f, 'line two: more text');
utl_file.fclose(f);
end;
/

Links
See also On reading trace files with PL/SQL where a directory is used to read trace files
with PL/SQL.

You might also like