Creating External Table.
Creating External Table.
Creating External Table.
DEFINITION:
External tables uses the SQL*Loader functionality to access data in the operating system files without ever loading the data into a real oracle table. It is possible to read and write to a external table. Basically the data dictionary holds the table definition but the data remains in the o/s file but you can access the table just like any other table. External table offers some advantages over SQL*Loader
table is
data must come from text datafiles. Loads from external tables to internal tables are done by reading from the text-only datafiles in the external table.
The ORACLE_DATAPUMP access driver can perform both loads and unloads. The data must
come from binary dump files. Loads to internal tables from external tables are done by fetching from the binary dump files. Unloads from internal tables to external tables are done by populating the binary dump files of the external table.
- specifies the default location of files that are read or written by external tables. The location is specified with a directory object, not a directory path.
DEFAULT DIRECTORY
- describe the external data source and implements the type of external table that was specified. Each type of external table has its own access driver that provides access parameters unique to that type of external table.
ACCESS PARAMETERS
- specifies the location of the external data. The location is specified as a list of directory objects and filenames. If the directory object is not specified, then the default directory object is used as the file location.
LOCATION
7. Load the data from the external table (i.e external_tab1) into normal table (i.e external2):
col type_name format a15 col reject_limit format a15 SELECT table_name, type_name, default_directory_name,ACCESS_PARAMETERS, reject_limit, access_type FROM user_external_tables; output:
9. All OS flat files associated to the external table exist in the OS directory
select * from user_external_locations where table_name='EXTERNAL_TAB1'; output:
Export Scott user using expdp command: expdp scott/tiger DIRECTORY=ODPDIR DUMPFILE=externaldat.dmp SCHEMAS=scott ACCESS_METHOD=EXTERNAL_TABLE parallel=2 Import dumpfile to rajesh user using impdp command: impdp scott/tiger DIRECTORY=ODPDIR DUMPFILE=externaldat.dmp REMAP_SCHEMA=scott:rajesh parallel=2
Query data before it's loaded into the tables Perform extensive range of transformations on the data during the load process itself. You can choose to perform data transformation at the same time you're loading the data into the tables, this is called pipelining Suitable for large data loads Saves time creating table to aggregate the data in to other tables Eliminate the creation of staging or temporary tables You do not need physical space for a external table You cannot perform any update or delete operations on external tables. One small note is that you cannot index a external table, so high powered query work is impractical, if you must have indexes then use SQL*Loader and load the data into staging table or a temporary table. External tables are heavy used in data warehousing environments. Queries of external tables complete very quickly, even though a full table scan is required with each access. There is I/O involved, but modern I/O systems use caching and RAID techniques to significantly reduce the performance penalty associated with repeated full scans of the same file.
Millions of data insert in External Tables: In flat file demo.dat stored 134099 datas. It takes few seconds to create external tables with 134099 records.