
{"id":7631,"date":"2020-02-28T09:54:59","date_gmt":"2020-02-28T09:54:59","guid":{"rendered":"https:\/\/rax-stg-wp-aws.com\/blogs\/use-oracle-external-tables\/"},"modified":"2026-11-03T19:28:47","modified_gmt":"2026-11-03T19:28:47","slug":"use-oracle-external-tables","status":"publish","type":"blogs","link":"https:\/\/www.rackspace.com\/en-gb\/blogs\/use-oracle-external-tables\/","title":{"rendered":"Use Oracle external tables"},"content":{"rendered":"<p><strong>Introduction<\/strong><\/p>\n<p>External tables receive data from the flat files stored outside of the database&nbsp;and allow Oracle\u00ae to query the data in those files. Oracle can parse any file format supported by the SQL\\*Loader. You can&#8217;t use data&nbsp;manipulation language (DML) on external tables, but you can use DML for query, join,&nbsp;and sort operations. You can also create views and synonyms against the external tables.<\/p>\n<p>To take advantage of the external table feature, you should use the ORACLE_LOADER&nbsp;access driver and make sure the data files are in the text format. You should&nbsp;also understand Structured Query Language (SQL) so you can create an external table and&nbsp;perform queries against it.&nbsp;<\/p>\n<p><strong>Make an external table in an Oracle database<\/strong><\/p>\n<p><strong>Create a directory<\/strong><\/p>\n<p>Oracle can parse any file format supported by the &#8220;SQL\\*Loader.&#8221; You can&#8217;t use data&nbsp;manipulation language (DML) on external tables, but you can use DML for query, join,&nbsp;and sort operations. You can also create views and synonyms against the external tables.<\/p>\n<p>To take advantage of the external table feature, you should use the ORACLE_LOADER&nbsp;access driver and make sure the data files are in the text format. You should&nbsp; also understand Structured Query Language (SQL) so you can create an external table and perform queries against it.<\/p>\n<p><strong>Make an external table in an Oracle database<\/strong><\/p>\n<p><strong>Create a directory<\/strong><\/p>\n<p>Use the following code to create a directory that points to the location of the&nbsp;comma-separated value (CSV) or text files provided by a user.<\/p>\n<p><em>&nbsp;create directory vk_dir as &#8216;\/opt\/oracle\/app\/admin\/je1prd\/mods\/151214_CHG0004529&#8217;;<\/em><\/p>\n<p><strong>Create an external table<\/strong><\/p>\n<p><em>Use the following SQL to create an external table:<\/em><\/p>\n<p><em>&nbsp; &nbsp; create table kumarv5.VK_4529_ext<br \/>\n&nbsp; &nbsp; (<br \/>\n&nbsp; &nbsp; &nbsp; IBMCU &nbsp; NCHAR(12),<br \/>\n&nbsp; &nbsp; &nbsp; IBLITM &nbsp; NCHAR(25),<br \/>\n&nbsp; &nbsp; &nbsp; IBANPL &nbsp; NUMBER<br \/>\n&nbsp; &nbsp; )<br \/>\n&nbsp; &nbsp; organization external<br \/>\n&nbsp; &nbsp; (<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;type oracle_loader<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;default directory vk_dir<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;access parameters<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;(<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;records delimited by newline<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;logfile vk_dir:&#8217;VK_4529_ext.log&#8217;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;badfile vk_dir:&#8217;VK_4529_ext.bad&#8217;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;discardfile vk_dir:&#8217;VK_4529_ext.dcf&#8217;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;skip 1<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fields<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;terminated by &#8216;~&#8217;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;missing field values are null<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reject rows with all null fields<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IBMCU,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IBLITM,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IBANPL<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;)<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;)<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;location<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;(<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#8216;data14.csv&#8217;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;)<br \/>\n&nbsp; &nbsp; )<br \/>\n&nbsp; &nbsp; reject limit unlimited;<\/em><\/p>\n<p><em>#### Create a local table<\/em><\/p>\n<p><em>Because you can&#8217;t perform DML on the external tables, use the following code to<br \/>\ncreate a local table based on the external one:<\/em><\/p>\n<p><em>&nbsp; &nbsp; &#8211;create<br \/>\n&nbsp; &nbsp; create table kumarv5.VK_4529_int<br \/>\n&nbsp; &nbsp; (<br \/>\n&nbsp; &nbsp; &nbsp; IBMCU &nbsp; NCHAR(12),<br \/>\n&nbsp; &nbsp; &nbsp; IBLITM &nbsp; NCHAR(25),<br \/>\n&nbsp; &nbsp; &nbsp; IBANPL &nbsp; NUMBER<br \/>\n&nbsp; &nbsp; )<br \/>\n&nbsp; &nbsp; tablespace proddtat;<\/em><br \/>\n&nbsp;<\/p>\n<p><strong>Copy data from the external to the local table<\/strong><\/p>\n<p>Use the following code to copy data from the external to the local table:<\/p>\n<p><em>&nbsp; &nbsp; &#8211;insert<br \/>\n&nbsp; &nbsp; Insert into kumarv5.VK_4529_int &nbsp; select * from kumarv5.VK_4529_ext;<br \/>\n&nbsp; &nbsp; commit;<br \/>\n&nbsp; &nbsp; select count(*) from kumarv5.VK_4529_int;<\/em><\/p>\n<p><strong>Update the main production table<\/strong><\/p>\n<p>After you create the local table based on the external one, you can use the following code to update the main production table from the local table:<\/p>\n<p><em>&nbsp; &nbsp; update PRODDTA.F43090 a<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; set a.PCMCU=&#8217; &nbsp; &nbsp; &nbsp; &nbsp; 1AM&#8217;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; WHERE (a. IBMCU, a. IBLITM, a. IBANPL) in<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(select b. IBMCU, b. IBLITM, b. IBANPL from kumarv5.VK_4529_int b );<\/em><\/p>\n<p><strong>Load data from external tables to regular tables<\/strong><\/p>\n<p>The following image shows you how to load data from an external table to a<br \/>\nregular table:<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26458-body-Picture1_9.png\" alt=\"oracle external pic 1\" \/><\/p>\n<p><a href=\"https:\/\/dba.fyicenter.com\/faq\/oracle\/Load-Data-from-External-Tables.html\"><em>Image Source<\/em><\/a><\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>External tables enable you to access data from external sources as if it were&nbsp;in a table in the database. If users provide data in a spreadsheet or CSV&nbsp;format, and you need to update database tables based on the Excel sheet, an&nbsp;external table comes in handy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use Oracle external tables<\/p>\n","protected":false},"author":2,"featured_media":7633,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","format":"standard","meta":{"content-type":"","nid":"26458","content_type":"blog","created_by":"10130","authored_on":"2024-01-08T09:54:59+00:00","field_article_industries":"","tag_category":"Technical","field_blog_author_text":"by Vikas Kumar, Oracle Database Administrator, Rackspace Technology","seo_description":"Query data from external files using Oracle external tables and leverage the power of SQL queries for seamless data retrieval and analysis.\r\n","field_featured_image":"","insights_image":"\/wp-content\/uploads\/2026\/blog_technical_images\/26458-insights_image-oracle-technical-blog-1-insights.jpg","field_partners":"","rxt_platforms":"Oracle","product":"","publisheddate":"2020-02-28T09:54:59","rxt_solutions":"Databases","opengraph_tag":"","x_tag":"","teaser_flag":"Technical Blog","seo_titile":"Oracle External Tables Flat Files Query | Rackspace Technology","field_topics":"","field_slug":"use-oracle-external-tables","footnotes":""},"categories":[178],"tags":[204],"class_list":["post-7631","blogs","type-blogs","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-technical"],"_links":{"self":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs\/7631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs"}],"about":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/types\/blogs"}],"author":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/comments?post=7631"}],"version-history":[{"count":3,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs\/7631\/revisions"}],"predecessor-version":[{"id":9573,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/blogs\/7631\/revisions\/9573"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/media\/7633"}],"wp:attachment":[{"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/media?parent=7631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/categories?post=7631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rackspace.com\/en-gb\/wp-json\/wp\/v2\/tags?post=7631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}