SlideShare a Scribd company logo
Oracle External Tables Gwendolyn Wright 11/07/02
Agenda Introduction Dictionary Objects and External Tables Creating an External Table Querying External Tables External Tables – Fixed Records Data Dictionary Views for External Tables Creating External Table Scripts External Table Advantages External Table Disadvantages Possible Issues Where to Get More Information
Introduction External tables are read-only tables that are defined in flat-files outside of the database but can be accessed by SQL inside of the database.  This feature can be used to load data into a database from flat files without using SQL*Loader.
Directory Objects and External tables Create a directory and grant read on the directory to a user. These tables are like regular SQL tables with some exceptions: - The metadata of external tables is created using the SQL “CREATE TABLE … ORGANIZATION EXTERNAL” statement. - The data resides outside the database in OS files, thus the EXTERNAL organization. - The OS files are identified inside the database through a logical directory defining the OS physical directory where they are located. - The data is read only. - You cannot perform any DML operations, nor create indexes. - The external table can be queried and joined directly, in parallel using the SQL statement SELECT.
Creating an External Table Create a flat file emp1.dat & emp2.dat Create a directory that defines the location of the directory where the flat files reside on the OS Create the external table (metadata) Select data from the external table to verify that data are visible
Querying External Tables External tables can be queried just like any other table.
External Tables – Fixed Records In addition to loading records with a variable format, we can also load them with a fixed format.
Data Dictionary Views for External Tables To get external tables names and characteristics, the DBA_EXTERNAL_TABLES view can be queried. If you need to retrieve the locations of the flat files, the view is DBA_EXTERNAL_LOCATIONS.
Creating External Table Scripts This is a new SQL*Loader option EXTERNAL_TABLE that can be used to create external tables as follows: - Create a sample data file for the external table - Create a SQL*Loader control script. - Run SQL*Loader using the control script to generate the commands for building an external table. - View the SQL*Loader log file.
External Tables Advantages The  EXTERNAL_TABLE command-line parameter: NOT USED  – This is the default value.  In this case, the load is done using conventional or direct path mode. GENERATE ONLY  – The load job is not performed.  Instead, all of the SQL statements to be executed for the whole load job are written to the specified SQL*Loader log file.  The load can be done later by executing the statements in the log file EXECUTE  – The load job is performed using external tables by executing SQL statements.  If any of the statements fail and return an error, the attempt to load stops.  Statements are always placed in the lof gile except the directory statements as they are executed. If the EXECUTE or GENERATE_ONLY option is specified, the userid that loads should be granted the following privileges: CREATE ANY DIRECTORY DROP ANY DIRECTORY
External Table Disadvantages In an external table load for which the data file character set is UTF8 or UTF16, it is not possible to suppress checking for byte-order marks.  The suppression is only necessary if the beginning of the data file contains binary data that matches the byte-order mark encloding.  It is possibel to suppress byte-order mark checking with usual loads.
Possible Issues Ownership of the External Tables
Where to Get More Information Oracle9i Recovering Lost Data  – Oracle Metalink – Doc 174425.1 Parameters FLASHBACK_SCN & FLASHBACK_TIME:   Point in Time Export – Oracle Metalink – Doc 204334.1 Flashback Query:  Confusion on SCN based  – Oracle Metalink –  Doc 302681.999 Oracle 9i New Features Flashback  – Oracle Metalink – Doc 143217.1

More Related Content

PDF
Oracle SQL Part 2
PPT
DOCX
PPT
Extracts from AS/400 Concepts & Tools workshop
DOCX
Sql loader good example
DOCX
Oracle sql loader utility
PPTX
Sql basics
PPTX
Dynamic Publishing with Arbortext Data Merge
Oracle SQL Part 2
Extracts from AS/400 Concepts & Tools workshop
Sql loader good example
Oracle sql loader utility
Sql basics
Dynamic Publishing with Arbortext Data Merge

What's hot (17)

ODP
Mysql database
ODT
ACADGILD:: HADOOP LESSON
PDF
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
ODP
Japer Reports
PPTX
PDF
Sql coding-standard-sqlserver
PPTX
Introduction to SQL
PPTX
Lab2 ddl commands
PPTX
Building Adaptive Payment Systems with YQL
PPTX
Difference Between Sql - MySql and Oracle
PPTX
Data stage
PPT
Sequences and indexes
PPTX
Unit1
PPT
SQL Server 2008 Performance Enhancements
PDF
Oracle10g External Tables
DOC
Mysql database
ACADGILD:: HADOOP LESSON
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Japer Reports
Sql coding-standard-sqlserver
Introduction to SQL
Lab2 ddl commands
Building Adaptive Payment Systems with YQL
Difference Between Sql - MySql and Oracle
Data stage
Sequences and indexes
Unit1
SQL Server 2008 Performance Enhancements
Oracle10g External Tables
Ad

Similar to Oracle External Tables (20)

PPT
Week 10-11 Managing Tablespaces and Data Files.ppt
PPTX
IDUG 2015 NA Data Movement Utilities final
PPT
Changing platforms of Oracle database
ODP
Introduction4 SQLite
PPTX
Big file tablespaces
PPT
Less17 Util
DOCX
Module 3 Notes.docx and pyspark being used
PPTX
View od dffmfmfmm,dm,f,dm,dfm,dddfdfsd,sd,sddf,df,ldf
PPTX
PostgreSQL Database Slides
PPTX
moving data between the data bases in database
PDF
sql_bootcamp.pdf
PPTX
Oracle architecture with details-yogiji creations
PPT
Optimizing Data Accessin Sq Lserver2005
PPTX
Getting to know oracle database objects iot, mviews, clusters and more…
PDF
Oracle Introduction
PDF
Dbmsunit v
PPTX
Sql in dbms
PDF
Structures query language ___PPT (1).pdf
PPTX
ELT Publishing Tool Overview V3_Jeff
PDF
Oracle Express Edition - Información de la Licencia (Library Manager).pdf
Week 10-11 Managing Tablespaces and Data Files.ppt
IDUG 2015 NA Data Movement Utilities final
Changing platforms of Oracle database
Introduction4 SQLite
Big file tablespaces
Less17 Util
Module 3 Notes.docx and pyspark being used
View od dffmfmfmm,dm,f,dm,dfm,dddfdfsd,sd,sddf,df,ldf
PostgreSQL Database Slides
moving data between the data bases in database
sql_bootcamp.pdf
Oracle architecture with details-yogiji creations
Optimizing Data Accessin Sq Lserver2005
Getting to know oracle database objects iot, mviews, clusters and more…
Oracle Introduction
Dbmsunit v
Sql in dbms
Structures query language ___PPT (1).pdf
ELT Publishing Tool Overview V3_Jeff
Oracle Express Edition - Información de la Licencia (Library Manager).pdf
Ad

Oracle External Tables

  • 1. Oracle External Tables Gwendolyn Wright 11/07/02
  • 2. Agenda Introduction Dictionary Objects and External Tables Creating an External Table Querying External Tables External Tables – Fixed Records Data Dictionary Views for External Tables Creating External Table Scripts External Table Advantages External Table Disadvantages Possible Issues Where to Get More Information
  • 3. Introduction External tables are read-only tables that are defined in flat-files outside of the database but can be accessed by SQL inside of the database. This feature can be used to load data into a database from flat files without using SQL*Loader.
  • 4. Directory Objects and External tables Create a directory and grant read on the directory to a user. These tables are like regular SQL tables with some exceptions: - The metadata of external tables is created using the SQL “CREATE TABLE … ORGANIZATION EXTERNAL” statement. - The data resides outside the database in OS files, thus the EXTERNAL organization. - The OS files are identified inside the database through a logical directory defining the OS physical directory where they are located. - The data is read only. - You cannot perform any DML operations, nor create indexes. - The external table can be queried and joined directly, in parallel using the SQL statement SELECT.
  • 5. Creating an External Table Create a flat file emp1.dat & emp2.dat Create a directory that defines the location of the directory where the flat files reside on the OS Create the external table (metadata) Select data from the external table to verify that data are visible
  • 6. Querying External Tables External tables can be queried just like any other table.
  • 7. External Tables – Fixed Records In addition to loading records with a variable format, we can also load them with a fixed format.
  • 8. Data Dictionary Views for External Tables To get external tables names and characteristics, the DBA_EXTERNAL_TABLES view can be queried. If you need to retrieve the locations of the flat files, the view is DBA_EXTERNAL_LOCATIONS.
  • 9. Creating External Table Scripts This is a new SQL*Loader option EXTERNAL_TABLE that can be used to create external tables as follows: - Create a sample data file for the external table - Create a SQL*Loader control script. - Run SQL*Loader using the control script to generate the commands for building an external table. - View the SQL*Loader log file.
  • 10. External Tables Advantages The EXTERNAL_TABLE command-line parameter: NOT USED – This is the default value. In this case, the load is done using conventional or direct path mode. GENERATE ONLY – The load job is not performed. Instead, all of the SQL statements to be executed for the whole load job are written to the specified SQL*Loader log file. The load can be done later by executing the statements in the log file EXECUTE – The load job is performed using external tables by executing SQL statements. If any of the statements fail and return an error, the attempt to load stops. Statements are always placed in the lof gile except the directory statements as they are executed. If the EXECUTE or GENERATE_ONLY option is specified, the userid that loads should be granted the following privileges: CREATE ANY DIRECTORY DROP ANY DIRECTORY
  • 11. External Table Disadvantages In an external table load for which the data file character set is UTF8 or UTF16, it is not possible to suppress checking for byte-order marks. The suppression is only necessary if the beginning of the data file contains binary data that matches the byte-order mark encloding. It is possibel to suppress byte-order mark checking with usual loads.
  • 12. Possible Issues Ownership of the External Tables
  • 13. Where to Get More Information Oracle9i Recovering Lost Data – Oracle Metalink – Doc 174425.1 Parameters FLASHBACK_SCN & FLASHBACK_TIME: Point in Time Export – Oracle Metalink – Doc 204334.1 Flashback Query: Confusion on SCN based – Oracle Metalink – Doc 302681.999 Oracle 9i New Features Flashback – Oracle Metalink – Doc 143217.1