Professional Documents
Culture Documents
https://oracle-base.com/articles/9i/external-tables-9i
1.Create directory
CREATE OR REPLACE DIRECTORY ext_tab_data AS '/data';
2.Provide the permissions to the library.
3.Create the external table using below
CREATE TABLE countries_ext (
country_code VARCHAR2(5),
country_name VARCHAR2(50),
country_language VARCHAR2(50)
)
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY ext_tab_data
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL
(
country_code CHAR(5),
country_name CHAR(50),
country_language CHAR(50)
)
)
LOCATION ('Countries1.txt','Countries2.txt')
)
PARALLEL 5
REJECT LIMIT UNLIMITED;
7. what is parsing?
12.UTL File:
This easy writing to the alert log is accomplished by using Oracle's utl_file
package. The Oracle utl_file package allows Oracle SQL and PL/SQL to read and write
directly from flat files on the server.
Writing custom messages to the Oracle alert log requires the following steps:
1 - Locate the background dump directory (the location of the alert log).
2 - Set the utl_file_dir initialization parameter.
3 - Execute utl_file.fopen to open the file for write access.
4 - Use dbms_output.put_line to write the custom message to the alert log.
5 - Execute utl_file.fclose to close the file
-- ******************************************************
-- Gather the location of the alert log directory
-- ******************************************************
select
name into :alert_loc
from
v$parameter
where
name = 'background_dump_destination';
-- ******************************************************
alter system set utl_file_dir = ':alert_log');
-- ******************************************************
-- Open the alert log file for write access
-- ******************************************************
utl_file.fopen(':alert_log','alertprod.log','W');
-- ******************************************************
-- Write the custom message to the alert log file
-- ******************************************************
dbms_output.put_line('invalid_application_error');
-- ******************************************************
-- Close the alert log file
-- ******************************************************
utl_file.fclose(':alert_loc');
Oracle lets a database program write to flat files using the utl_file utility
FILE SYSTEM 3