

{"id":6740,"date":"2018-02-01T13:29:24","date_gmt":"2018-02-01T13:29:24","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=6740"},"modified":"2023-08-17T22:58:21","modified_gmt":"2023-08-17T17:28:21","slug":"apache-sqoop-tutorial","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/","title":{"rendered":"Apache Sqoop Tutorial &#8211; Learn Sqoop from Beginner to Expert"},"content":{"rendered":"<p><span style=\"font-weight: 400\">Big Data tool, which\u00a0we use for transferring data between <strong>Hadoop<\/strong> and relational database servers is what we call Sqoop. In this Apache Sqoop Tutorial, we will learn the whole concept regarding Sqoop. We will study What is Sqoop, several prerequisites required to learn Sqoop, Sqoop Releases, Sqoop Commands, and Sqoop Tools. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Afterward, we will move forward to the basic usage of Sqoop. Moving forward, we will also learn how Sqoop works. Moreover, we will also learn Sqoop Import and Sqoop Export with Sqoop Example.<\/span><\/p>\n<p>So, let&#8217;s start our Sqoop Tutorial.<\/p>\n<h3>What is Apache Sqoop?<\/h3>\n<p>An open-source data integration programme called Apache Sqoop is intended to make it easier to move data between Apache Hadoop and conventional relational databases or other structured data repositories. The difficulty of effectively integrating data from external systems into Hadoop&#8217;s distributed file system (HDFS) and exporting processed or analysed data back to relational databases for use in business intelligence or reporting tools is addressed.<\/p>\n<p>Data import from several relational databases, including MySQL, Oracle, SQL Server, and PostgreSQL, into HDFS is one of Sqoop&#8217;s core functionalities. It enables incremental imports, allowing users to import just the new or changed records since the last import, minimising data transfer time and guaranteeing data consistency. Parallel imports are supported, enabling the efficient transfer of big datasets.<\/p>\n<p>When it comes to exporting, Sqoop makes it possible to send processed or analysed data from HDFS back to relational databases, guaranteeing that the knowledge obtained from big data analysis can be incorporated into current data warehousing systems without any difficulty.<\/p>\n<p>Additionally, Sqoop is essential for connecting with other Hadoop ecosystem parts, such as Apache Hive for data warehousing. Since Sqoop is versatile for usage in scripts and automated processes thanks to its command-line interface (CLI) and APIs, developers may successfully integrate it into their data pipelines. Sqoop is a flexible and useful solution for large data integration projects because of its extensible design, which allows for new connections to enable additional data sources beyond those supported by its built-in connectors<\/p>\n<p><span style=\"font-weight: 400\">Basically, Sqoop (\u201cSQL-to-Hadoop\u201d) is a straightforward command-line tool. It offers the following capabilities:<\/span><\/p>\n<ol>\n<li><span style=\"font-weight: 400\">Generally,\u00a0helps to Import individual tables or entire databases to files in HDFS<\/span><\/li>\n<li><span style=\"font-weight: 400\">Also can Generate Java classes to allow you to interact with your imported data<\/span><\/li>\n<li><span style=\"font-weight: 400\">Moreover, it offers the ability to import from SQL databases straight into your <strong>Hive <\/strong>data warehouse.<\/span><\/li>\n<\/ol>\n<h3>Sqoop Tutorial &#8211; Releases<\/h3>\n<p><span style=\"font-weight: 400\">Basically, Apache Sqoop is an Apache Software Foundation\u2019s open source software product. Moreover, we can download Sqoop Software from\u00a0<\/span><span style=\"font-weight: 400\">http:\/\/sqoop.apache.org<\/span><span style=\"font-weight: 400\">. Basically, at that site, you can obtain:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">All the new releases of Sqoop, as well as its most recent source code.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">An issue tracker <\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Also, a wiki that contains Sqoop documentation<\/span><\/li>\n<\/ul>\n<h3>Prerequisites to learn Sqoop<\/h3>\n<p><span style=\"font-weight: 400\">In Apache Sqoop tutorial, we are going to study prerequisites to learn Sqoop. Such as:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Basic computer technology and terminology.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">General familiarity with Sqoop command-line interfaces like bash and many more.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Relational database management systems.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">General familiarity with Hadoop\u2019s purpose and operation. <\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">Basically, an important thing to note that to use Apache Sqoop, we need a release of <strong>Hadoop installation and configuration<\/strong>. Although, currently Sqoop is supporting 4 major\u00a0<\/span><span style=\"font-weight: 400\">Hadoop releases. Such as &#8211; 0.20, 0.23, 1.0 and 2.0.<\/span><\/p>\n<p>In addition, be assured that you are using a Linux or the Linux-like environment. Also, remember that Sqoop is predominantly operated and tested on <strong>Linux.<\/strong><\/p>\n<h3>Sqoop Tutorial &#8211;\u00a0 Tools<\/h3>\n<p><span style=\"font-weight: 400\">Basically, Sqoop attains the collection of related tools. We can use Sqoop, by just specifying the tool we want to use but with the arguments that control the tool.<\/span><\/p>\n<div id=\"attachment_10769\" style=\"width: 1090px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Sqoop-Tools-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-10769\" class=\"wp-image-10769 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Sqoop-Tools-01.jpg\" alt=\"Apache Sqoop Tutorial\" width=\"1080\" height=\"1080\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Sqoop-Tools-01.jpg 1080w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Sqoop-Tools-01-150x150.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Sqoop-Tools-01-300x300.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Sqoop-Tools-01-768x768.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Sqoop-Tools-01-1024x1024.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Sqoop-Tools-01-100x100.jpg 100w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/a><p id=\"caption-attachment-10769\" class=\"wp-caption-text\">Apache Sqoop Tutorial -Sqoop Tools<\/p><\/div>\n<p>In addition, Since Sqoop is compiled from its own source, by running the bin\/sqoop program we can run Sqoop without a formal installation process. Also, users of a packaged deployment of Sqoop will see this program installed as \/usr\/bin\/sqoop. Such as an RPM shipped with Apache Bigtop. Moreover, the remainder of this documentation will refer to this program as sqoop. For example:<br \/>\n<b><\/b><\/p>\n<p><b>$ sqoop tool-name [tool-arguments]<\/b><\/p>\n<p><span style=\"font-weight: 400\">Here, an example that starts with a $ character indicates that the commands must be entered at a terminal prompt. For example bash. Basically, $ character shows the prompt itself. Moreover, note that we should not start these commands by typing a $. Also, we can enter commands inline in the text of a paragraph such as sqoop help.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Although, these examples do not show a $ prefix. However, we should enter them the same way. Make sure that you don\u2019t confuse the $ shell prompt in the examples with the $. Since that precedes an environment variable name. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Like, here the string literal $HADOOP_HOME includes a &#8220;$&#8221;.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Basically, Sqoop ships with a help tool. Type the following Sqoop command, to display a list of all available tools:<\/span><br \/>\n<b><\/b><\/p>\n<p><b>$ sqoop help<\/b><\/p>\n<p>usage: sqoop COMMAND [ARGS]<\/p>\n<p><strong>Table. 1 Sqoop Tutorial &#8211; Available Sqoop commands<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td>codegen<\/td>\n<td>Generate code to interact with database records<\/td>\n<\/tr>\n<tr>\n<td>Create-hive- table<\/td>\n<td>Import a table definition into Hive<\/td>\n<\/tr>\n<tr>\n<td>eval<\/td>\n<td>Evaluate a SQL statement and display the results<\/td>\n<\/tr>\n<tr>\n<td>export<\/td>\n<td>Export an HDFS directory to a database table<\/td>\n<\/tr>\n<tr>\n<td>help<\/td>\n<td>List available commands<\/td>\n<\/tr>\n<tr>\n<td>import<\/td>\n<td>Import a table from a database to HDFS<\/td>\n<\/tr>\n<tr>\n<td>Import-all-tables<\/td>\n<td>Import tables from a database to HDFS<\/td>\n<\/tr>\n<tr>\n<td>list-databases<\/td>\n<td>List available databases on a server<\/td>\n<\/tr>\n<tr>\n<td>list-tables<\/td>\n<td>List available tables in a database<\/td>\n<\/tr>\n<tr>\n<td>version<\/td>\n<td>Display version information<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Also, by entering\u00a0sqoop help (tool-name), we can display help for a specific tool. Like, sqoop help import.<\/p>\n<p>In addition, we can also add the &#8211;help argument to any Sqoop command: sqoop import &#8211;help.<\/p>\n<h4>a. Using Command Aliases<\/h4>\n<p><span style=\"font-weight: 400\">We can use alias scripts by typing the sqoop (toolname) syntax. Basically, that specifies the sqoop-(toolname) syntax. Like, the scripts sqoop-import, sqoop-export and many more. Although, each select a specific tool.<\/span><\/p>\n<h4>b. Controlling the Hadoop Installation<\/h4>\n<p><span style=\"font-weight: 400\">To elicit Sqoop we can use the program launch capability provided by Hadoop. To run the bin\/hadoop script shipped with Hadoop, we can use the sqoop command-line program wrapper. Since there are multiple installations of Hadoop present on your machine, we can easily select the Hadoop installation just by setting the $HADOOP_COMMON_HOME <\/span><span style=\"font-weight: 400\">and $HADOOP_MAPRED_HOME environment variables.<\/span><\/p>\n<p><strong>For example-<\/strong><\/p>\n<p>$ HADOOP_COMMON_HOME=\/path\/to\/some\/hadoop \\<\/p>\n<p>HADOOP_MAPRED_HOME=\/path\/to\/some\/hadoop-mapreduce \\<\/p>\n<p>sqoop import &#8211;arguments&#8230;<\/p>\n<p><strong>or:<\/strong><\/p>\n<p>$ export HADOOP_COMMON_HOME=\/some\/path\/to\/hadoop<\/p>\n<p>$ export HADOOP_MAPRED_HOME=\/some\/path\/to\/hadoop-mapreduce<\/p>\n<p>$ sqoop import &#8211;arguments\u2026<\/p>\n<p><span style=\"font-weight: 400\">Keep in mind that if either of these variables is not set, Sqoop will fall back to <\/span><span style=\"font-weight: 400\">$HADOOP_HOME. Although if that is not set either for Apache Bigtop, Sqoop will use the default installation locations, \/usr\/lib\/Hadoop and \/usr\/lib\/Hadoop-MapReduce, respectively.<\/span><\/p>\n<p><span style=\"font-weight: 400\">In addition, from $HADOOP_HOME\/conf\/ the active Hadoop configuration is loaded. Till <\/span><span style=\"font-weight: 400\">the $HADOOP_CONF_DIR environment variable is set.<\/span><\/p>\n<h4>c. Using Generic and Specific Arguments<\/h4>\n<p><span style=\"font-weight: 400\">Basically, we can use generic and specific arguments to control the operation of each Sqoop tool.<\/span><br \/>\n<b><\/b><\/p>\n<p><b>For example-<\/b><\/p>\n<p>$ sqoop help import<\/p>\n<p>usage: sqoop import [GENERIC-ARGS] [TOOL-ARGS]<\/p>\n<p><strong>Table. 2 Sqoop Tutorial &#8211;\u00a0Common arguments<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;connect &lt;jdbc-uri&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Specify JDBC connect string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;connect-manager &lt;jdbc-uri&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Specify connection manager class to use<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;driver &lt;class-name&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Manually specify JDBC driver class to use<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;hadoop-mapred-home &lt;dir&gt;+ \u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">Override $HADOOP_MAPRED_HOME<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;help<\/span><\/td>\n<td><span style=\"font-weight: 400\">Print usage instructions<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;P<\/span><\/td>\n<td><span style=\"font-weight: 400\">Read password from console<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;password &lt;password&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Set authentication password<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;username &lt;username&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Set authentication username<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;verbose \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">Print more information while working<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;hadoop-home &lt;dir&gt;+ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">Deprecated. Override $HADOOP_HOME<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>[&#8230;]<\/p>\n<p><span style=\"font-weight: 400\"><strong>Table. 3 Sqoop Tutorial &#8211;\u00a0\u00a0Common arguments<\/strong><\/span><\/p>\n<p><span style=\"font-weight: 400\">Generic Hadoop command-line arguments:<\/span><\/p>\n<p><span style=\"font-weight: 400\">(must preceed any tool-specific arguments)<\/span><\/p>\n<p><span style=\"font-weight: 400\">Generic options supported are \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">-conf &lt;configuration file&gt; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">specify an application configuration file<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">-D &lt;property=value&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">use value for given property<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">-fs &lt;local|namenode:port&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">specify a namenode<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">-jt &lt;local|jobtracker:port&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\"> \u00a0specify a job tracker<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">-files &lt;comma separated list of files&gt; \u00a0\u00a0\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">specify comma diffrentiate files to be copied to the map reduce cluster<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">-libjars &lt;comma separated list of jars&gt; \u00a0\u00a0\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">specify comma separated jar files to include in the classpath.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">-archives &lt;comma separated list of archives&gt; \u00a0\u00a0\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">specify comma separated archives to be unarchived on the compute machines.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>The general command line syntax is<\/strong><\/p>\n<p>bin\/hadoop command [genericOptions] [commandOptions]<\/p>\n<p><span style=\"font-weight: 400\">It is essential to supply the generic arguments after the tool name like -conf, -D, and so on. <\/span><\/p>\n<p><span style=\"font-weight: 400\">However, it must be before any tool-specific arguments like &#8211;connect. <\/span><br \/>\n<b><\/b><\/p>\n<p><b>Note: <\/b><span style=\"font-weight: 400\">Here, generic Hadoop arguments are preceded by a single dash character (-). However, tool-specific arguments start with two dashes (&#8211;), until and unless they are single character arguments like -P.<\/span><\/p>\n<p><span style=\"font-weight: 400\">In addition, some arguments control the configuration and Hadoop server settings. Like -conf, -D, -fs and -jt. For example, to set the name of the MR job that Sqoop launches, we can use the -D mapred.job.name=&lt;job_name&gt;. Although, if not specified, the name defaults to the jar name for the job that is derived from the used table name.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Well we can not use are typically use -files, -libjars, and -archives arguments in Sqoop. However, as part of Hadoop\u2019s internal argument-parsing system, their arguments are included in it.<\/span><\/p>\n<h4>d. Using Options Files to Pass Arguments<\/h4>\n<p><span style=\"font-weight: 400\">For convenience, the Sqoop command line options that do not change from invocation to invocation can be put in options file in Sqoop. Basically, an options file can be defined as a text file. In a text file, each line identifies an option in the order that it appears otherwise on the command line. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Moreover, \u00a0by using the backslash character at the end of intermediate lines, an options file allows specifying a single option on multiple lines. Although, on a new line, comments must be specified. Also, important that may not be mixed with option text. However, when option files have expanded, all comments and empty lines are ignored. <\/span><\/p>\n<p><span style=\"font-weight: 400\">We can also specify an options file, by simply creating an options file in a convenient location and pass it to the command line. By using &#8211;options-file argument.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Although, it is expanded on the Sqoop command line before the tool is invoked, whenever options file is specified. Moreover, if needed we can specify more than one option files within the same invocation.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Let\u2019s see this as an example. Here, the following Sqoop invocation for import can be specified alternatively as shown below:<\/span><\/p>\n<p>$ sqoop import &#8211;connect jdbc:mysql:\/\/localhost\/db &#8211;username foo &#8211;table TEST<\/p>\n<p>$ sqoop &#8211;options-file \/users\/homer\/work\/import.txt &#8211;table TEST<br \/>\n<b><\/b><\/p>\n<p><b>where the options file \/users\/homer\/work\/import.txt contains the following:<\/b><\/p>\n<p>import<\/p>\n<p>&#8211;connect<\/p>\n<p>jdbc:mysql:\/\/localhost\/db<\/p>\n<p>&#8211;username<\/p>\n<p>foo<\/p>\n<p><span style=\"font-weight: 400\">For readability purposes, the options file can have empty lines and comments. So the above example would work exactly the same if the options file <\/span><\/p>\n<p><span style=\"font-weight: 400\">\/users\/homer\/work\/import.txt contained the following:<\/span><\/p>\n<p>#<\/p>\n<p># Options file for Sqoop import<\/p>\n<p>#<\/p>\n<p># Specifies the tool being invoked<\/p>\n<p>import<\/p>\n<p># Connect parameter and value<\/p>\n<p>&#8211;connect<\/p>\n<p>jdbc:mysql:\/\/localhost\/db<\/p>\n<p># Username parameter and value<\/p>\n<p>&#8211;username<\/p>\n<p>foo<\/p>\n<p>#<\/p>\n<p># Remaining options should be specified in the command line.<\/p>\n<p>#<\/p>\n<h3>How Sqoop Works?<\/h3>\n<p><span style=\"font-weight: 400\">Let&#8217;s move forward in Sqoop tutorial. Here, below image describes the workflow of Sqoop.<\/span><\/p>\n<div id=\"attachment_6744\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Working-of-Sqoop-01-1.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-6744\" class=\"wp-image-6744 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Working-of-Sqoop-01-1.jpg\" alt=\"Apache Sqoop Tutorial - Working of Sqoop\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Working-of-Sqoop-01-1.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Working-of-Sqoop-01-1-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Working-of-Sqoop-01-1-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Working-of-Sqoop-01-1-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Working-of-Sqoop-01-1-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-6744\" class=\"wp-caption-text\">Apache Sqoop Tutorial &#8211; Working of Sqoop<\/p><\/div>\n<h3>Sqoop Import<\/h3>\n<p><span style=\"font-weight: 400\">Basically, when it comes to importing tool, it imports individual tables from RDBMS to HDFS. Here, in HDFS each row in a table is treated as a record. Moreover, in Avro and Sequence files all records are stored as text data in text files or as binary data.<\/span><\/p>\n<h4>a. Purpose of Sqoop Import<\/h4>\n<p><span style=\"font-weight: 400\">From an RDBMS to HDFS, the import tool imports an individual table. Here, in HDFS each row from a table is represented as a separate record. Moreover, we can store Records as text files (one record per line). However, \u00a0in binary representation as Avro or SequenceFiles.<\/span><\/p>\n<h4>b. Syntax<\/h4>\n<p><span style=\"font-weight: 400\">We can type the import arguments in any order with respect to one another, while the Hadoop generic arguments must precede any import arguments only.<\/span><\/p>\n<p>The important thing to note here is that arguments are grouped into collections organized by function. Basically, some collections are present in several tools. For example, the &#8220;common&#8221; arguments.<br \/>\n<b><\/b><\/p>\n<p><b><strong>Table. 4 Sqoop Tutorial &#8211;\u00a0<\/strong> Common arguments<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Argument<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td>&#8211;connect &lt;jdbc-uri&gt;<\/td>\n<td>Specify JDBC connect string<\/td>\n<\/tr>\n<tr>\n<td>&#8211;connection-manager &lt;class-name&gt;<\/td>\n<td>Specify connection manager class to use<\/td>\n<\/tr>\n<tr>\n<td>&#8211;driver &lt;class-name&gt;<\/td>\n<td>Manually specify JDBC driver class to use<\/td>\n<\/tr>\n<tr>\n<td>&#8211;hadoop-mapped-home &lt;dir&gt;<\/td>\n<td>Override $HADOOP_MAPRED_HOME<\/td>\n<\/tr>\n<tr>\n<td>&#8211;help<\/td>\n<td>Print usage instructions<\/td>\n<\/tr>\n<tr>\n<td>&#8211;password-file<\/td>\n<td>Set path for a file containing the authentication password<\/td>\n<\/tr>\n<tr>\n<td>-P<\/td>\n<td>Read password from console<\/td>\n<\/tr>\n<tr>\n<td>&#8211;password &lt;password&gt;<\/td>\n<td>Set authentication password<\/td>\n<\/tr>\n<tr>\n<td>&#8211;username &lt;username&gt;<\/td>\n<td>Set authentication username<\/td>\n<\/tr>\n<tr>\n<td>&#8211;verbose<\/td>\n<td>Print more information while working<\/td>\n<\/tr>\n<tr>\n<td>&#8211;connection-param-file &lt;filename&gt;<\/td>\n<td>Optional properties file that provides connection parameters<\/td>\n<\/tr>\n<tr>\n<td>&#8211;relaxed-isolation<\/td>\n<td>Set connection transaction isolation to read uncommitted for the mappers.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Sqoop Export<\/h3>\n<p><span style=\"font-weight: 400\">When we want to export a set of files from HDFS back to an RDBMS we use the export tool. Basically, there are rows in table those are the files which are input to Sqoop those contains records, which we call as rows in the table. Although, those files are read and parsed into a set of records. Also, delimited with the user-specified delimiter.<\/span><\/p>\n<h4>a. Purpose of Sqoop export<\/h4>\n<p><span style=\"font-weight: 400\">When we want to export a set of files from HDFS back to an RDBMS we use the export tool. One condition is here, the target table must already exist in the database. <\/span><\/p>\n<p>In addition, to transform these into a set of INSERT statements, the default operation is that inject the records into the database. Moreover, Sqoop will generate UPDATE statements in &#8220;update mode,&#8221; that replace existing records in the database. Whereas, in &#8220;call mode&#8221; Sqoop will make a stored procedure call for each record.<\/p>\n<h4>b. Syntax<\/h4>\n<p>$ sqoop export (generic-args) (export-args)<\/p>\n<p>$ sqoop-export (generic-args) (export-args)<\/p>\n<p>Basically, \u00a0the export arguments can be entered in any order with respect to one another,<\/p>\n<p>However, the Hadoop generic arguments must precede any export arguments.<br \/>\n<b><\/b><\/p>\n<p><b><strong>Table. 5 Sqoop Tutorial &#8211;\u00a0<\/strong> Common arguments<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">Argument<\/span><\/td>\n<td><span style=\"font-weight: 400\">Description<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;connect &lt;jdbc-uri&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Specify JDBC connect string<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;connection-manager &lt;class-name&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Specify connection manager class to use<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;driver &lt;class-name&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Manually specify JDBC driver class to use<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;hadoop-mapred-home &lt;dir&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Override $HADOOP_MAPRED_HOME<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;help<\/span><\/td>\n<td><span style=\"font-weight: 400\">Print usage instructions<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;password-file<\/span><\/td>\n<td><span style=\"font-weight: 400\">Set path for a file containing the authentication password<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">-P<\/span><\/td>\n<td><span style=\"font-weight: 400\">Read password from console<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;password &lt;password&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Set authentication password<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;username &lt;username&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Set authentication username<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;verbose<\/span><\/td>\n<td><span style=\"font-weight: 400\">Print more information while working<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;connection-param-file &lt;filename&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Optional properties file that provides connection parameters<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><b><strong>Table. 6 Sqoop Tutorial &#8211;\u00a0<\/strong> Validation arguments More Details<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">Argument<\/span><\/td>\n<td><span style=\"font-weight: 400\">Description<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;validate<\/span><\/td>\n<td><span style=\"font-weight: 400\">Enable validation of data copied, supports single table copy only.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;validator &lt;class-name&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Specify validator class to use.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;validation-threshold &lt;class-name&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Specify validation threshold class to use.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;validation-failurehandler &lt;class-name&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Specify validation failure handler class to use.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><b><strong>Table. 7 Sqoop Tutorial &#8211;\u00a0<\/strong> Export control arguments:<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">Argument<\/span><\/td>\n<td><span style=\"font-weight: 400\">Description<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;columns &lt;col,col,col\u2026&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Columns to export to table<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;direct<\/span><\/td>\n<td><span style=\"font-weight: 400\">Use direct export fast path<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;export-dir &lt;dir&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">HDFS source path for the export<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">-m,&#8211;num-mappers &lt;n&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Use n map tasks to export in parallel<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;table &lt;table-name&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Table to populate<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;call &lt;stored-proc-name&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Stored Procedure to call<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;update-key &lt;col-name&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Anchor column to use for updates. Use a comma separated list of columns if there are more than one column.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;update-mode &lt;mode&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Specify how updates are performed when new rows are found with non-matching keys in database.Legal values for mode include updateonly (default) and allowinsert.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;input-null-string &lt;null-string&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">The string to be interpreted as null for string columns<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;input-null-non-string &lt;null-string&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">The string to be interpreted as null for non-string columns<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;staging-table &lt;staging-table-name&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">The table in which data will be staged before being inserted into the destination table.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;clear-staging-table<\/span><\/td>\n<td><span style=\"font-weight: 400\">Indicates that any data present in the staging table can be deleted.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;batch<\/span><\/td>\n<td><span style=\"font-weight: 400\">Use batch mode for underlying statement execution.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>To specify the table to populate the database and the directory in HDFS that contains the source data.\u00a0The &#8211;export-dir argument and one of &#8211;table or &#8211;call is all we want.<\/p>\n<p><span style=\"font-weight: 400\">The important thing to note is that support for staging data prior to pushing it into the destination table is not always available for &#8211;direct exports. Also, we can say it is not available when export is invoked using the &#8211;update-key option for updating existing data. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Even when procedures are stored it used to insert the data.\u00a0<\/span><\/p>\n<h4>c. Inserts vs. Updates<\/h4>\n<p><span style=\"font-weight: 400\">By default, sqoop-export appends new rows to a table; each input record is transformed into an INSERT statement that adds a row to the target database table. If your table has constraints (e.g., a primary key column whose values must be unique) and already contains data, you must take care to avoid inserting records that violate these constraints. <\/span><\/p>\n<p><span style=\"font-weight: 400\">The export process will fail if an INSERT statement fails. This mode is primarily intended for exporting records to a new, empty table intended to receive these results.<\/span><br \/>\nIf you specify the &#8211;update-key argument, Sqoop will instead modify an existing dataset in the database. Each input record is treated as an UPDATE statement that modifies an existing row. The row a statement modifies is determined by the column name(s) specified with &#8211;update-key. For example, consider the following table definition:<\/p>\n<p>CREATE TABLE foo(<\/p>\n<p>id INT NOT NULL PRIMARY KEY,<\/p>\n<p>msg VARCHAR(32),<\/p>\n<p>bar INT);<br \/>\n<b><\/b><\/p>\n<p><b>Consider also a dataset in HDFS containing records like these:<\/b><\/p>\n<p>0, this is a test,42<\/p>\n<p>1, some more data,100<\/p>\n<p>&#8230;<br \/>\n<b><\/b><\/p>\n<p><b>Running sqoop-export &#8211;table foo &#8211;update-key id &#8211;export-dir \/path\/to\/data &#8211;connect \u2026 <\/b><b>will run an export job that executes SQL statements based on the data like so:<\/b><\/p>\n<p>UPDATE foo SET msg=&#8217;this is a test&#8217;, bar=42 WHERE id=0;<\/p>\n<p>UPDATE foo SET msg=&#8217;some more data&#8217;, bar=100 WHERE id=1;<\/p>\n<p>\u2026<\/p>\n<p>If an UPDATE statement modifies no rows, this is not considered an error; the export will silently continue. (In effect, this means that an update-based export will not insert new rows into the database.) Likewise, if the column specified with &#8211;update-key does not uniquely identify rows and multiple rows are updated by a single statement, this condition is also undetected.<\/p>\n<p>The argument &#8211;update-key can also be given a comma-separated list of column names. In which case, Sqoop will match all keys from this list before updating an existing record.<\/p>\n<p>Depending on the target database, you may also specify the &#8211;update-mode argument with allowing insert mode if you want to update rows if they exist in the database already or insert rows if they do not exist yet.<br \/>\n<b><\/b><\/p>\n<p><b><strong>Table. 8 Sqoop Tutorial &#8211;\u00a0<\/strong> Input parsing arguments:<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">Argument<\/span><\/td>\n<td><span style=\"font-weight: 400\">Description<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;input-enclosed-by &lt;char&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sets a required field encloser<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;input-escaped-by &lt;char&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sets the input escape character<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;input-fields-terminated-by &lt;char&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sets the input field separator<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;input-lines-terminated-by &lt;char&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sets the input end-of-line character<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;input-optionally-enclosed-by &lt;char&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sets a field enclosing character<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><b><strong>Table. 9 Sqoop Tutorial &#8211;\u00a0<\/strong> Output line formatting arguments:<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">Argument<\/span><\/td>\n<td><span style=\"font-weight: 400\">Description<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;enclosed-by &lt;char&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sets a required field enclosing character<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;escaped-by &lt;char&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sets the escape character<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;fields-terminated-by &lt;char&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sets the field separator character<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;lines-terminated-by &lt;char&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sets the end-of-line character<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;mysql-delimiters<\/span><\/td>\n<td><span style=\"font-weight: 400\">Uses MySQL\u2019s default delimiter set: fields: , lines: \\n escaped-by: \\ optionally-enclosed-by: <\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;optionally-enclosed-by &lt;char&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sets a field enclosing character<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Basically, Sqoop generates code to parse and interpret records of the files containing the data to be exported back to the database. If these files were created with non-default delimiters (comma-separated fields with newline-separated records), you should specify the same delimiters again so that Sqoop can parse your files.<\/p>\n<p>Also, Sqoop will fail to find enough columns per line if you specify the incorrect delimiter. This will cause export map tasks to fail by throwing ParseExceptions.<br \/>\n<b><\/b><\/p>\n<p><b><strong>Table. 10 Sqoop Tutorial &#8211;\u00a0<\/strong>\u00a0&#8211; Code generation arguments:<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">Argument<\/span><\/td>\n<td><span style=\"font-weight: 400\">Description<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;bindir &lt;dir&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Output directory for compiled objects<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;class-name &lt;name&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sets the generated class name. This overrides &#8211;package-name. When combined with &#8211;jar-file, sets the input class.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;jar-file &lt;file&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Disable code generation; use specified jar<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;outdir &lt;dir&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Output directory for generated code<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;package-name &lt;name&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Put auto-generated classes in this package<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">&#8211;map-column-java &lt;m&gt;<\/span><\/td>\n<td><span style=\"font-weight: 400\">Override default mapping from SQL type to Java type for configured columns.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Specifying &#8211;jar-file and &#8211;class-name obviate the need to specify delimiters in this case.<br \/>\nIn addition, the use of the existing code is incompatible with &#8211;update-key. Basically, an update-mode export requires new code generation to perform the update. You cannot use &#8211;jar-file, and must fully specify any non-default delimiters.<\/p>\n<h4>d. Exports and Transactions<\/h4>\n<p><span style=\"font-weight: 400\">Basically, by multiple writers, it performs exports in parallel. Here, to the database each writer uses a separate connection; these have separate transactions from one another. Moreover, Sqoop uses the multi-row INSERT syntax to insert up to 100 records per statement.<\/span><\/p>\n<p><span style=\"font-weight: 400\"> Also, every 100 statements commit the current transaction within a writing task, causing a commit every 10,000 rows. Also, it ensures that transaction buffers do not grow without bound, and cause out-of-memory conditions. Therefore, an export is not an atomic process. Partial results from the export will become visible before the export is complete.<\/span><\/p>\n<h4>e. Failed Exports<\/h4>\n<p><span style=\"font-weight: 400\">However, there are no. of reasons for which exports may fail such as:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">When there is a loss of connectivity from the Hadoop cluster to the database. It can be for many reasons like due to the hardware fault, or server software crashes.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">While we attempt to INSERT a row that violates a consistency constraint. For example, inserting a duplicate primary key value.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Also, by attempting to parse an incomplete or malformed record from the HDFS source data<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">By using incorrect delimiters while it attempts to parse records <\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Due to some capacity issues.\u00a0For Example,\u00a0insufficient RAM or disk space.<\/span><\/li>\n<\/ul>\n<p>Due to these or other reasons, if an export map task fails, it may cause the export job to fail. Although, failed exports just have undefined results. Also, we can say each export map task operates in a separate transaction. Moreover, individual map tasks commit their current transaction periodically.\u00a0 However, in the database any previously-committed transactions will remain durable, leading to a partially-complete export.<\/p>\n<h3>Sqoop Tutorial &#8211; Usage<\/h3>\n<p><span style=\"font-weight: 400\">In this Sqoop Tutorial, we study Working, import, export, release, and tools now look at usage of sqoop. Basically, by using Sqoop\u00a0we can easily import data from a relational database system. Also possible from a mainframe to HDFS. Although to import process, the input is either database table or mainframe datasets. <\/span><\/p>\n<p><span style=\"font-weight: 400\">However, Sqoop will read the table row-by-row into HDFS for databases. Whereas, Sqoop will read records from each mainframe dataset into HDFS for mainframe datasets. Furthermore, a set of files containing a copy of the imported table or datasets is the output of this import process. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Therefore, it performs the import process in parallel. For this reason, the output will be in multiple files.\u00a0<\/span><\/p>\n<p>Moreover, there are some other Sqoop commands. Also,\u00a0allow us to inspect the database you are working with. For example, you can list the available database schemas and tables within a schema. Sqoop also includes a primitive SQL execution shell (the sqoop-eval tool).<\/p>\n<p>In addition, we can customize most aspects of the import, code generation, and export processes. Furthermore, we can control the specific row range or columns imported from databases. Basically, we\u00a0can specify particular delimiters. Also, can escape characters for the file-based representation of the data, as well as the file format used. Moreover, we can also control the class or package names used in generated code.<\/p>\n<p>So, this was all in Apache Sqoop Tutorial. Hope you like our explanation.<\/p>\n<h3>Conclusion &#8211; Sqoop Tutorial<\/h3>\n<p>As a result, we have seen in this <strong>Apache Sqoop <\/strong>Tutorial, what is Sqoop. Moreover, we have learned all the tools, working, and Sqoop commands. Also, we have learned the way to Import and Export Sqoop. Afterward, we have learned in Apache Sqoop Tutorial, basic usage of Sqoop. However, if you want to ask any query regarding Sqoop Tutorial, feel free to ask in the comment section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Big Data tool, which\u00a0we use for transferring data between Hadoop and relational database servers is what we call Sqoop. In this Apache Sqoop Tutorial, we will learn the whole concept regarding Sqoop. We will&#46;&#46;&#46;<\/p>\n","protected":false},"author":9,"featured_media":10768,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[68],"tags":[969,973,975,1665,7116,8148,9949,13596,13601,13602,13608,13621,13622,13629,13646,13670,13673,13680,13681,15978],"class_list":["post-6740","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sqoop","tag-apache-sqoop","tag-apache-sqoop-tutorial","tag-apache-sqoop-working","tag-basic-usage-of-sqoop","tag-introduction-to-sqoop","tag-learn-how-sqoop-works","tag-prerequisites-to-learn-sqoop","tag-sqoop","tag-sqoop-basic","tag-sqoop-basics","tag-sqoop-commands","tag-sqoop-example","tag-sqoop-export","tag-sqoop-import","tag-sqoop-introduction","tag-sqoop-releases","tag-sqoop-tools","tag-sqoop-tutorial","tag-sqoop-useage","tag-what-is-sqoop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Apache Sqoop Tutorial &#8211; Learn Sqoop from Beginner to Expert - DataFlair<\/title>\n<meta name=\"description\" content=\"Apache Sqoop Tutorial-what is sqoop,sqoop import,Sqoop export &amp; Usage,working of sqoop with commands,sqoop history &amp; tools,How to learn Sqoop,\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apache Sqoop Tutorial &#8211; Learn Sqoop from Beginner to Expert - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Apache Sqoop Tutorial-what is sqoop,sqoop import,Sqoop export &amp; Usage,working of sqoop with commands,sqoop history &amp; tools,How to learn Sqoop,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-02-01T13:29:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-17T17:28:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Apache-Sqoop-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apache Sqoop Tutorial &#8211; Learn Sqoop from Beginner to Expert - DataFlair","description":"Apache Sqoop Tutorial-what is sqoop,sqoop import,Sqoop export & Usage,working of sqoop with commands,sqoop history & tools,How to learn Sqoop,","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:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Apache Sqoop Tutorial &#8211; Learn Sqoop from Beginner to Expert - DataFlair","og_description":"Apache Sqoop Tutorial-what is sqoop,sqoop import,Sqoop export & Usage,working of sqoop with commands,sqoop history & tools,How to learn Sqoop,","og_url":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-02-01T13:29:24+00:00","article_modified_time":"2023-08-17T17:28:21+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Apache-Sqoop-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/6e11a88eea98179e861a0933f8959f8f"},"headline":"Apache Sqoop Tutorial &#8211; Learn Sqoop from Beginner to Expert","datePublished":"2018-02-01T13:29:24+00:00","dateModified":"2023-08-17T17:28:21+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/"},"wordCount":3983,"commentCount":2,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Apache-Sqoop-01.jpg","keywords":["Apache Sqoop","Apache Sqoop Tutorial","Apache Sqoop working","Basic Usage of Sqoop","Introduction to Sqoop","learn how Sqoop works","prerequisites to learn Sqoop","Sqoop","sqoop basic","sqoop basics","Sqoop Commands","Sqoop Example","sqoop export","sqoop import","Sqoop introduction","Sqoop Releases","Sqoop Tools","Sqoop Tutorial","sqoop useage","What is Sqoop"],"articleSection":["Sqoop Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/","url":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/","name":"Apache Sqoop Tutorial &#8211; Learn Sqoop from Beginner to Expert - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Apache-Sqoop-01.jpg","datePublished":"2018-02-01T13:29:24+00:00","dateModified":"2023-08-17T17:28:21+00:00","description":"Apache Sqoop Tutorial-what is sqoop,sqoop import,Sqoop export & Usage,working of sqoop with commands,sqoop history & tools,How to learn Sqoop,","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Apache-Sqoop-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Apache-Sqoop-01.jpg","width":1200,"height":628,"caption":"Apache Sqoop Tutorial"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/apache-sqoop-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Sqoop Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/sqoop\/"},{"@type":"ListItem","position":3,"name":"Apache Sqoop Tutorial &#8211; Learn Sqoop from Beginner to Expert"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/6e11a88eea98179e861a0933f8959f8f","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/54363d8635c383dcd7e3be0ef00dbeef4217c45bf323d27bc2c92366b724df08?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/54363d8635c383dcd7e3be0ef00dbeef4217c45bf323d27bc2c92366b724df08?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/54363d8635c383dcd7e3be0ef00dbeef4217c45bf323d27bc2c92366b724df08?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"At DataFlair, our team of experts is committed to offering high-quality tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We simplify learning to help you advance your career in the tech world.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam5\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/6740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=6740"}],"version-history":[{"count":11,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/6740\/revisions"}],"predecessor-version":[{"id":118513,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/6740\/revisions\/118513"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/10768"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=6740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=6740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=6740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}