472,371 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 472,371 developers and data experts.

USING EXTERNAL TABLE

debasisdas
8,127 Expert 4TB
This thread contains some useful tips for using External tables.


USING EXTERNAL TABLE
=======================
1.THE TABLE POINTS TO EXTERNAL FILE. IF DATA IS ALTERED IN THE EXTERNAL FILE,DATA IN THE TABLE WILL ALSO CHANGE.
2.EXTERNAL TABLES CAN BE QUERIED IN THE SAME WAY AS STANDARD TABLES IN JOINS,VIEWS.....AND CAN USE ALL TYPES OF FUNCTION ON THE EXTERNAL TABLE.
3.TO GET INFO REGARDING EXTERNAL TABLES QUERY THE "USER_EXTERNAL_TABLES" DATA DICTIONARY VIEW.
4."USER_EXTERNAL_TABLES" DOES NOT SHOW THE NAME OF THE EXTERNAL FILE TO WHICH THE TABLE POINTS.FOR THIS QUERY "USER_EXTERNAL_LOCATIONS"
5.USER CAN'T PERFORM ANY 'DML' OPERATION ON EXTERNAL TABLES.
6.EXTERNAL TABLES CAN'T BE INDEXED.
7.CONSTAINTS CAN'T BE SPECIFIED ON EXTERNAL TABLES,NOT EVEN A NOT NULL OR FOREIGN KEY CONSTRAINT.

First create a directory using following sample code.
Expand|Select|Wrap|Line Numbers
  1. CREATE DIRECTORY MYDIR AS 'D:\';
  2.  
Place the source file in the specified directory (path as above)

Data in the file should be specific to match the table structure.

Next

Grant read,write pregiledges to specified user.

Expand|Select|Wrap|Line Numbers
  1. GRANT READ,WRITE ON DIRECTORY MYDIR TO DEBASIS;
  2.  
Sample code to create EXTERNAL TABLE

Expand|Select|Wrap|Line Numbers
  1. create table extemp1
  2. (
  3. empno number(4),
  4. ename varchar2(10),
  5. JOB VARCHAR2(9),
  6. MGR NUMBER(4),
  7. HIREDATE DATE,
  8. SAL NUMBER(7,2),
  9. COMM NUMBER(7,2),
  10. DEPTNO NUMBER(2)
  11. )
  12. ORGANIZATION EXTERNAL
  13. (
  14. TYPE ORACLE_LOADER
  15. DEFAULT DIRECTORY MYDIR
  16. ACCESS PARAMETERS
  17. (
  18. RECORDS DELIMITED BY NEWLINE SKIP 1
  19. FIELDS TERMINATED BY ','
  20. (
  21. empno CHAR,
  22. ename CHAR,
  23. JOB CHAR,
  24. MGR CHAR,
  25. HIREDATE CHAR,
  26. SAL CHAR,
  27. COMM CHAR,
  28. DEPTNO CHAR
  29. ))
  30. LOCATION('DATA.LST')
  31. )
  32. REJECT LIMIT 1
  33. ;
  34.  
Sample example #2
======================
Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE TABLE SCOTT.et
  3. (
  4.   id    NUMBER(8,3),
  5.   name  VARCHAR2(10)
  6. )
  7. ORGANIZATION EXTERNAL
  8.   (  TYPE ORACLE_LOADER
  9.      DEFAULT DIRECTORY DDD
  10.      ACCESS PARAMETERS 
  11.        (        RECORDS DELIMITED BY NEWLINE
  12.        BADFILE DDD:'et.bad'
  13.        DISCARDFILE DDD:'et.dsc'
  14.        LOGFILE DDD:'et.log'
  15.        READSIZE 512
  16.        DATE_CACHE 1000
  17.        SKIP 0
  18.        FIELDS TERMINATED BY ','
  19.        MISSING FIELD VALUES ARE NULL
  20.        REJECT ROWS WITH ALL NULL FIELDS
  21.        (
  22.          id CHAR,
  23.          name CHAR
  24.        ) )
  25.      LOCATION (DDD:'aa.txt')
  26.   )
  27. REJECT LIMIT Unlimited
  28. NOPARALLEL
  29. NOMONITORING;
  30.  
May 11 '07 #1
0 8523

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Erohsik | last post by:
I am using external tables to load data from the data file. But the log files are getting created in the datafile's directory (because of CREATE OR REPLACE DIRECTORY ...) But I want those log...
0
by: Sameers (theAngrycodeR) via .NET 247 | last post by:
I think I will get MAD very soon. Its very weired problem I amfacing here. Let me explain. I have two DBF files from which I want to export data in CSVformat. I created a desktop application and...
0
by: Learner | last post by:
Gurus, I have a C# .NET Web application that downloads a datagrid to an Excel sheet. But when I upload the same excel sheet to server again, if gives me this wiered message "External table is...
1
by: monishkar | last post by:
Can two external table functions in DB2 LUW have the same name even though they have different specific_name? Thanks.
0
by: aniendow | last post by:
Hi All, I am trying to upload a TAB delimited file into a database table. Considering the performance issue I thought EXTERNAL TABLE is my best option but with one problem, My table has CLOB...
0
by: Ujval Shah | last post by:
Hi, I am facing a peculiar problem. My Client Requirement is to Export and Import Excel from and To DataSet for web Application using OWC. Now Problem is When i Export file using OWC .. File's...
5
by: Patrick | last post by:
I have set the Navigation Pane so that it is not displayed on startup of my application. However, if I programmatically link to an external Access table, the navigation pane automatically...
3
by: tundal45 | last post by:
Hey Guys, I am trying to automate the process of loading data in our oracle server. As a part of that process, I am working on a perl script that loads external tables from data files. What I am...
7
by: gyanendar | last post by:
Hi All, I need to create an external table to extract data from a flat file which having only one field. Also from that field first two character should not come in the table. Please help me...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.