{"id":19771,"date":"2024-03-15T19:26:16","date_gmt":"2024-03-15T19:26:16","guid":{"rendered":"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/"},"modified":"2024-03-21T16:29:50","modified_gmt":"2024-03-21T16:29:50","slug":"how-to-export-data-from-a-database-table-using-pl-sql","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/","title":{"rendered":"How to export data from a database table using PL\/SQL?"},"content":{"rendered":"<p>In PL\/SQL, you have the option to export data from database tables using either the DBMS_DATAPUMP package or the EXPDP tool. Two methods are available for you to choose from.<\/p>\n<p>Option 1: Utilize the DBMS_DATAPUMP package.<\/p>\n<p>The DBMS_DATAPUMP is an Oracle built-in package for data pump operations. It allows you to export and import database objects and data using PL\/SQL code. Below is an example code of using DBMS_DATAPUMP to export database table data.<\/p>\n<pre class=\"post-pre\">DECLARE<p><\/p><p>&nbsp;&nbsp;--&nbsp;\u5b9a\u4e49\u53d8\u91cf<\/p><p>&nbsp;&nbsp;handle&nbsp;NUMBER;<\/p><p>BEGIN<\/p><p>&nbsp;&nbsp;--&nbsp;\u521d\u59cb\u5316\u5bfc\u51fa\u4efb\u52a1<\/p><p>&nbsp;&nbsp;handle&nbsp;:=&nbsp;DBMS_DATAPUMP.OPEN(operation&nbsp;=&gt;&nbsp;'EXPORT',&nbsp;job_mode&nbsp;=&gt;&nbsp;'SCHEMA',&nbsp;job_name&nbsp;=&gt;&nbsp;<\/p><p>&nbsp;&nbsp;'EXPORT_TABLE_DATA');<\/p><p>&nbsp;&nbsp;--&nbsp;\u6dfb\u52a0\u8981\u5bfc\u51fa\u7684\u8868<\/p><p>&nbsp;&nbsp;DBMS_DATAPUMP.ADD_FILE(handle,&nbsp;file_name&nbsp;=&gt;&nbsp;'EXPORT_TABLE_DATA.dmp',&nbsp;directory&nbsp;=&gt;&nbsp;<\/p><p>&nbsp;&nbsp;'DATA_PUMP_DIR',&nbsp;filetype&nbsp;=&gt;&nbsp;DBMS_DATAPUMP.KU$_FILE_TYPE_DUMP_FILE);<\/p><p>&nbsp;&nbsp;DBMS_DATAPUMP.METADATA_FILTER(handle,&nbsp;'SCHEMA_EXPR',&nbsp;name&nbsp;=&gt;&nbsp;'&lt;schema_name&gt;',&nbsp;value&nbsp;=&gt;&nbsp;'');<\/p><p>&nbsp;&nbsp;DBMS_DATAPUMP.METADATA_FILTER(handle,&nbsp;'NAME_EXPR',&nbsp;name&nbsp;=&gt;&nbsp;'&lt;table_name&gt;',&nbsp;value&nbsp;=&gt;&nbsp;'');<\/p><p>&nbsp;&nbsp;--&nbsp;\u5f00\u59cb\u5bfc\u51fa<\/p><p>&nbsp;&nbsp;DBMS_DATAPUMP.START_JOB(handle);<\/p><p>&nbsp;&nbsp;--&nbsp;\u7b49\u5f85\u5bfc\u51fa\u5b8c\u6210<\/p><p>&nbsp;&nbsp;DBMS_DATAPUMP.WAIT_FOR_JOB(handle,&nbsp;TRUE);<\/p><p>&nbsp;&nbsp;--&nbsp;\u5173\u95ed\u5bfc\u51fa\u4efb\u52a1<\/p><p>&nbsp;&nbsp;DBMS_DATAPUMP.CLOSE(handle);<\/p><p>END;<\/p><p>\/<\/p><\/pre>\n<p>Please note that in the above code, <schema_name> and <table_name> respectively represent the schema name and table name to be exported, you need to replace them with actual values.<\/p>\n<p>Option 2: Utilize the EXPDP tool.<\/p>\n<p>EXPDP is a command-line tool provided by Oracle for data pump operations. You can export database table data by running the following command in the operating system&#8217;s command line interface.<\/p>\n<pre class=\"post-pre\">expdp&nbsp;&lt;\u7528\u6237\u540d&gt;\/&lt;\u5bc6\u7801&gt;&nbsp;DIRECTORY=&lt;\u76ee\u5f55\u540d\u79f0&gt;&nbsp;DUMPFILE=&lt;\u5bfc\u51fa\u6587\u4ef6\u540d&gt;.dmp&nbsp;TABLES=&lt;\u6a21\u5f0f\u540d\u79f0&gt;.&lt;\u8868\u540d\u79f0&gt;<\/pre>\n<p>Please replace the following parts of the above command with the actual values.<\/p>\n<pre class=\"post-pre\">&lt;\u7528\u6237\u540d&gt;:&nbsp;\u6570\u636e\u5e93\u7528\u6237\u7684\u7528\u6237\u540d<p><\/p><p>&lt;\u5bc6\u7801&gt;:&nbsp;\u6570\u636e\u5e93\u7528\u6237\u7684\u5bc6\u7801<\/p><p>&lt;\u76ee\u5f55\u540d\u79f0&gt;:&nbsp;\u5bfc\u51fa\u6587\u4ef6\u7684\u76ee\u5f55\u540d\u79f0\uff08\u9700\u8981\u5728\u6570\u636e\u5e93\u4e2d\u63d0\u524d\u521b\u5efa\uff09<\/p><p>&lt;\u5bfc\u51fa\u6587\u4ef6\u540d&gt;:&nbsp;\u5bfc\u51fa\u6587\u4ef6\u7684\u540d\u79f0<\/p><p>&lt;\u6a21\u5f0f\u540d\u79f0&gt;:&nbsp;\u8981\u5bfc\u51fa\u7684\u6a21\u5f0f\u540d\u79f0<\/p><p>&lt;\u8868\u540d\u79f0&gt;:&nbsp;\u8981\u5bfc\u51fa\u7684\u8868\u540d\u79f0<\/p><\/pre>\n<p>After executing the above command, the exported data will be saved to the specified export file.<\/p>\n<p>Here are two commonly used methods for exporting database table data. You can choose one based on your own needs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In PL\/SQL, you have the option to export data from database tables using either the DBMS_DATAPUMP package or the EXPDP tool. Two methods are available for you to choose from. Option 1: Utilize the DBMS_DATAPUMP package. The DBMS_DATAPUMP is an Oracle built-in package for data pump operations. It allows you to export and import database [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-19771","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to export data from a database table using PL\/SQL? - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to export data from a database table using PL\/SQL?\" \/>\n<meta property=\"og:description\" content=\"In PL\/SQL, you have the option to export data from database tables using either the DBMS_DATAPUMP package or the EXPDP tool. Two methods are available for you to choose from. Option 1: Utilize the DBMS_DATAPUMP package. The DBMS_DATAPUMP is an Oracle built-in package for data pump operations. It allows you to export and import database [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-15T19:26:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-21T16:29:50+00:00\" \/>\n<meta name=\"author\" content=\"Noah Thompson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:site\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Noah Thompson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/\"},\"author\":{\"name\":\"Noah Thompson\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/2e83cc6ab9f60d36921c2d0f9f280f4a\"},\"headline\":\"How to export data from a database table using PL\/SQL?\",\"datePublished\":\"2024-03-15T19:26:16+00:00\",\"dateModified\":\"2024-03-21T16:29:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/\"},\"wordCount\":202,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/\",\"name\":\"How to export data from a database table using PL\/SQL? - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\"},\"datePublished\":\"2024-03-15T19:26:16+00:00\",\"dateModified\":\"2024-03-21T16:29:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.silicloud.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to export data from a database table using PL\/SQL?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"name\":\"Silicon Cloud Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\",\"name\":\"Silicon Cloud Blog\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"contentUrl\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"width\":1024,\"height\":1024,\"caption\":\"Silicon Cloud Blog\"},\"image\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\",\"https:\/\/twitter.com\/SiliCloudGlobal\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/2e83cc6ab9f60d36921c2d0f9f280f4a\",\"name\":\"Noah Thompson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/350e537e1530ede2762ee0237e877d6693f4f7163ab4f303202cc9a6b27b6cb4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/350e537e1530ede2762ee0237e877d6693f4f7163ab4f303202cc9a6b27b6cb4?s=96&d=mm&r=g\",\"caption\":\"Noah Thompson\"},\"url\":\"https:\/\/www.silicloud.com\/blog\/author\/noahthompson\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to export data from a database table using PL\/SQL? - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/","og_locale":"en_US","og_type":"article","og_title":"How to export data from a database table using PL\/SQL?","og_description":"In PL\/SQL, you have the option to export data from database tables using either the DBMS_DATAPUMP package or the EXPDP tool. Two methods are available for you to choose from. Option 1: Utilize the DBMS_DATAPUMP package. The DBMS_DATAPUMP is an Oracle built-in package for data pump operations. It allows you to export and import database [&hellip;]","og_url":"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/","og_site_name":"Blog - Silicon Cloud","article_publisher":"https:\/\/www.facebook.com\/SiliCloudGlobal\/","article_published_time":"2024-03-15T19:26:16+00:00","article_modified_time":"2024-03-21T16:29:50+00:00","author":"Noah Thompson","twitter_card":"summary_large_image","twitter_creator":"@SiliCloudGlobal","twitter_site":"@SiliCloudGlobal","twitter_misc":{"Written by":"Noah Thompson","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/#article","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/"},"author":{"name":"Noah Thompson","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/2e83cc6ab9f60d36921c2d0f9f280f4a"},"headline":"How to export data from a database table using PL\/SQL?","datePublished":"2024-03-15T19:26:16+00:00","dateModified":"2024-03-21T16:29:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/"},"wordCount":202,"commentCount":0,"publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/","url":"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/","name":"How to export data from a database table using PL\/SQL? - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/#website"},"datePublished":"2024-03-15T19:26:16+00:00","dateModified":"2024-03-21T16:29:50+00:00","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/blog\/how-to-export-data-from-a-database-table-using-pl-sql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.silicloud.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to export data from a database table using PL\/SQL?"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/blog\/#website","url":"https:\/\/www.silicloud.com\/blog\/","name":"Silicon Cloud Blog","description":"","publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.silicloud.com\/blog\/#organization","name":"Silicon Cloud Blog","url":"https:\/\/www.silicloud.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","contentUrl":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","width":1024,"height":1024,"caption":"Silicon Cloud Blog"},"image":{"@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/SiliCloudGlobal\/","https:\/\/twitter.com\/SiliCloudGlobal"]},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/2e83cc6ab9f60d36921c2d0f9f280f4a","name":"Noah Thompson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/350e537e1530ede2762ee0237e877d6693f4f7163ab4f303202cc9a6b27b6cb4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/350e537e1530ede2762ee0237e877d6693f4f7163ab4f303202cc9a6b27b6cb4?s=96&d=mm&r=g","caption":"Noah Thompson"},"url":"https:\/\/www.silicloud.com\/blog\/author\/noahthompson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/19771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/comments?post=19771"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/19771\/revisions"}],"predecessor-version":[{"id":53530,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/19771\/revisions\/53530"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/media?parent=19771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/categories?post=19771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/tags?post=19771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}