<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>export &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/export/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Fri, 15 Sep 2017 11:43:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>MySQL: Import and Export CSV data with Headers</title>
		<link>https://www.dbrnd.com/2015/09/mysql-import-and-export-csv-data-with-headers/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 29 Sep 2015 17:23:16 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[CSV File]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[MySQL Command]]></category>
		<category><![CDATA[MySQL Database Administrator]]></category>
		<category><![CDATA[MySQL Database Designing]]></category>
		<category><![CDATA[MySQL Database Programming]]></category>
		<category><![CDATA[MySQL Error]]></category>
		<category><![CDATA[MySQL Performance Tunning]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[MySQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=744</guid>

					<description><![CDATA[In this post, I am sharing a demonstration on how to export or import CSV data using MySQL INFILE and OUTFILE. The CSV files are most famous for the basic data migration activities. Database developer does not need to write or create any particular database link between two servers. They can easily import data from [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fmysql-import-and-export-csv-data-with-headers%2F&amp;linkname=MySQL%3A%20Import%20and%20Export%20CSV%20data%20with%20Headers" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fmysql-import-and-export-csv-data-with-headers%2F&amp;linkname=MySQL%3A%20Import%20and%20Export%20CSV%20data%20with%20Headers" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fmysql-import-and-export-csv-data-with-headers%2F&amp;linkname=MySQL%3A%20Import%20and%20Export%20CSV%20data%20with%20Headers" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fmysql-import-and-export-csv-data-with-headers%2F&amp;linkname=MySQL%3A%20Import%20and%20Export%20CSV%20data%20with%20Headers" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fmysql-import-and-export-csv-data-with-headers%2F&amp;linkname=MySQL%3A%20Import%20and%20Export%20CSV%20data%20with%20Headers" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fmysql-import-and-export-csv-data-with-headers%2F&amp;linkname=MySQL%3A%20Import%20and%20Export%20CSV%20data%20with%20Headers" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fmysql-import-and-export-csv-data-with-headers%2F&#038;title=MySQL%3A%20Import%20and%20Export%20CSV%20data%20with%20Headers" data-a2a-url="https://www.dbrnd.com/2015/09/mysql-import-and-export-csv-data-with-headers/" data-a2a-title="MySQL: Import and Export CSV data with Headers"></a></p><p>In this post, I am sharing a demonstration on how to export or import CSV data using MySQL INFILE and OUTFILE.</p>
<blockquote><p>The CSV files are most famous for the basic data migration activities.<br />
Database developer does not need to write or create any particular database link between two servers.<br />
They can easily import data from CSV and export that CSV data into another server and also CSV file does not have any data length limitation like XLS file.<br />
User can store millions of records into CSV file.</p></blockquote>
<p>This technique is preferred only for temporary purposes, and if it continues the process, the user has to write some automatic process like database server replication.</p>
<blockquote data-secret="cChVq1yzf8" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2015/09/import-or-export-a-csv-file-using-postgresql-copy-command/">Import or Export a CSV File using PostgreSQL COPY Command</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/09/import-or-export-a-csv-file-using-postgresql-copy-command/embed/#?secret=cChVq1yzf8" data-secret="cChVq1yzf8" width="600" height="338" title="&#8220;Import or Export a CSV File using PostgreSQL COPY Command&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>MySQL provides a different way to manage, data import and export in the CSV format.</p>
<p>You can also perform this exercise using MySQL workbench Import/Export wizard.</p>
<p>Very soon, I will prepare and share a video help for this workbench related solution.</p>
<p>Let me demonstrate it:</p>
<p>First, I created a table and import data from CSV file.<br />
I already created a CSV file with sample data. Make sure that, your table column and CSV column would be same.<br />
You can create this CSV file using a comma delimited save as option of Microsoft excel.</p>
<p><a href="https://www.dbrnd.com/wp-content/uploads/2015/09/PostgresCSV.png"><img fetchpriority="high" decoding="async" class="alignnone wp-image-683 size-full" title="MySQL CSV" src="https://www.dbrnd.com/wp-content/uploads/2015/09/PostgresCSV.png" alt="MySQL CSV" width="565" height="493" srcset="https://www.dbrnd.com/wp-content/uploads/2015/09/PostgresCSV.png 565w, https://www.dbrnd.com/wp-content/uploads/2015/09/PostgresCSV-300x262.png 300w, https://www.dbrnd.com/wp-content/uploads/2015/09/PostgresCSV-150x131.png 150w" sizes="(max-width: 565px) 100vw, 565px" /></a></p>
<p><strong> Create a sample table:</strong></p><pre class="crayon-plain-tag">CREATE TABLE TestCSV 
(
    Rno INTEGER
    ,Name VARCHAR(50)
);</pre><p>
<p><strong>Now COPY data from the CSV file into this table:</strong></p><pre class="crayon-plain-tag">LOAD DATA INFILE 'E:/dbrnd.com/TestCSV.csv' 
INTO TABLE TestCSV 
FIELDS TERMINATED BY ',' 
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;</pre><p>
<p>You should ignore the first row because of CSV headers.</p>
<p><strong>Check your sample table:</strong></p><pre class="crayon-plain-tag">SELECT *from TestCSV</pre><p>
<a href="https://www.dbrnd.com/wp-content/uploads/2015/09/MySQLCSVTableData.png"><img decoding="async" class="alignnone wp-image-750 size-full" title="MySQL CSV Table Data" src="https://www.dbrnd.com/wp-content/uploads/2015/09/MySQLCSVTableData.png" alt="MySQL CSV Table Data" width="120" height="205" /></a></p>
<p><strong>You can also import particular column from CSV file to MySQL Table:</strong></p><pre class="crayon-plain-tag">LOAD DATA LOCAL INFILE 'E:/dbrnd.com/TestCSV.csv'  INTO TABLE TestCSV
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'  
IGNORE 1 ROWS
(@col1,@col2) set name=@col2;</pre><p>
<p>As you can see in the above script, I used query variable and @col1 stores all Rno data, and this is working as a dummy import for column Rno.<br />
I set values for Name column by assigning @col2, so this query only import second column data, and the first column would be NULL.</p>
<p><strong>Now, script for export MySQL table data into CSV File:</strong></p><pre class="crayon-plain-tag">SELECT 
    IFNULL(Rno,'N/A')
    ,Name
FROM TestCSV
INTO OUTFILE 'E:/dbrnd.com/TestCSV2.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';</pre><p>
<p>After execution of the above query, please check your newly created CSV File.<br />
Note: This query will create a new CSV file at the specified path.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Import or Export a CSV File using PostgreSQL COPY Command</title>
		<link>https://www.dbrnd.com/2015/09/import-or-export-a-csv-file-using-postgresql-copy-command/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 20 Sep 2015 17:45:59 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[COPY FROM]]></category>
		<category><![CDATA[COPY TO]]></category>
		<category><![CDATA[CSV File]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=673</guid>

					<description><![CDATA[In this post, I am sharing a demonstration on how to export or import CSV data using the PostgreSQL COPY command. The CSV files are most famous for the necessary data migration activities. Database developer does not need to write or create any particular database link between two servers. They can easily import data in [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fimport-or-export-a-csv-file-using-postgresql-copy-command%2F&amp;linkname=Import%20or%20Export%20a%20CSV%20File%20using%20PostgreSQL%20COPY%20Command" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fimport-or-export-a-csv-file-using-postgresql-copy-command%2F&amp;linkname=Import%20or%20Export%20a%20CSV%20File%20using%20PostgreSQL%20COPY%20Command" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fimport-or-export-a-csv-file-using-postgresql-copy-command%2F&amp;linkname=Import%20or%20Export%20a%20CSV%20File%20using%20PostgreSQL%20COPY%20Command" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fimport-or-export-a-csv-file-using-postgresql-copy-command%2F&amp;linkname=Import%20or%20Export%20a%20CSV%20File%20using%20PostgreSQL%20COPY%20Command" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fimport-or-export-a-csv-file-using-postgresql-copy-command%2F&amp;linkname=Import%20or%20Export%20a%20CSV%20File%20using%20PostgreSQL%20COPY%20Command" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fimport-or-export-a-csv-file-using-postgresql-copy-command%2F&amp;linkname=Import%20or%20Export%20a%20CSV%20File%20using%20PostgreSQL%20COPY%20Command" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F09%2Fimport-or-export-a-csv-file-using-postgresql-copy-command%2F&#038;title=Import%20or%20Export%20a%20CSV%20File%20using%20PostgreSQL%20COPY%20Command" data-a2a-url="https://www.dbrnd.com/2015/09/import-or-export-a-csv-file-using-postgresql-copy-command/" data-a2a-title="Import or Export a CSV File using PostgreSQL COPY Command"></a></p><p>In this post, I am sharing a demonstration on how to export or import CSV data using the PostgreSQL COPY command.</p>
<blockquote><p>The CSV files are most famous for the necessary data migration activities. Database developer does not need to write or create any particular database link between two servers.</p>
<p>They can easily import data in CSV and export that CSV into another server and also CSV file does not have any data length limitation like any other XLS file. </p>
<p>User can store millions of records into CSV file.</p></blockquote>
<p>This technique is preferred only for temporary purposes, and if it continues the process, the user has to write some automated process like database server replication.</p>
<p>PostgreSQL provides the COPY command to import or export CSV data into the PostgreSQL table.</p>
<p>Let me demonstrate this:</p>
<p>First, I create one table and import data from CSV file. I have already created a CSV file with sample data. Make sure that, your table column and CSV column would be same.</p>
<p>You can create this CSV file using a comma delimited save as option of Microsoft excel.</p>
<p><a href="https://www.dbrnd.com/wp-content/uploads/2015/09/PostgresCSV.png"><img loading="lazy" decoding="async" class="alignnone wp-image-683 size-full" title="Postgres CSV" src="https://www.dbrnd.com/wp-content/uploads/2015/09/PostgresCSV.png" alt="Postgres CSV" width="565" height="493" srcset="https://www.dbrnd.com/wp-content/uploads/2015/09/PostgresCSV.png 565w, https://www.dbrnd.com/wp-content/uploads/2015/09/PostgresCSV-300x262.png 300w, https://www.dbrnd.com/wp-content/uploads/2015/09/PostgresCSV-150x131.png 150w" sizes="auto, (max-width: 565px) 100vw, 565px" /></a></p><pre class="crayon-plain-tag">CREATE TABLE tbl_testcsv
(
  rno integer,
  name character varying
);</pre><p>
<p><strong>Now COPY the data from CSV file into the table:</strong></p><pre class="crayon-plain-tag">COPY tbl_testcsv FROM 'E:\dbrnd.com\Postwork\testcsv.csv'
WITH DELIMITER ','
CSV HEADER;</pre><p>
<p><strong>After executing of COPY command, you can check the result:</strong></p><pre class="crayon-plain-tag">SELECT *FROM tbl_testcsv;</pre><p>
<a href="https://www.dbrnd.com/wp-content/uploads/2015/09/CSVTablelData.png"><img loading="lazy" decoding="async" class="alignnone wp-image-685 size-full" title="Postgres CSV Tablel Data" src="https://www.dbrnd.com/wp-content/uploads/2015/09/CSVTablelData.png" alt="Postgres CSV Tablel Data" width="230" height="226" srcset="https://www.dbrnd.com/wp-content/uploads/2015/09/CSVTablelData.png 230w, https://www.dbrnd.com/wp-content/uploads/2015/09/CSVTablelData-150x147.png 150w" sizes="auto, (max-width: 230px) 100vw, 230px" /></a></p>
<p><strong>Add some more records in Table and then we export the data into CSV file:</strong></p><pre class="crayon-plain-tag">INSERT INTO tbl_testcsv
VALUES 
(9,'YRQ'),(10,'QWE')
,(11,'MNB'),(12,'FGH');</pre><p>
<p><strong>Now, export this data using the COPY command:</strong></p><pre class="crayon-plain-tag">COPY tbl_testcsv TO 'E:\dbrnd.com\Postwork\testcsv.csv'
WITH DELIMITER ','
CSV HEADER;
--Query returned successfully: 12 rows affected,</pre><p>
<p><strong>Now, check your CSV file. You can find newly inserted data:</strong></p>
<p><a href="https://www.dbrnd.com/wp-content/uploads/2015/09/CSVExcelData.png"><img loading="lazy" decoding="async" class="alignnone wp-image-687 size-full" title="Postgres CSV Excel Data" src="https://www.dbrnd.com/wp-content/uploads/2015/09/CSVExcelData.png" alt="" width="198" height="336" srcset="https://www.dbrnd.com/wp-content/uploads/2015/09/CSVExcelData.png 198w, https://www.dbrnd.com/wp-content/uploads/2015/09/CSVExcelData-177x300.png 177w, https://www.dbrnd.com/wp-content/uploads/2015/09/CSVExcelData-150x255.png 150w" sizes="auto, (max-width: 198px) 100vw, 198px" /></a></p>
<p><strong>You can also define a particular column or write a full select statement in the COPY command:</strong><br />
Below is a sample script.</p><pre class="crayon-plain-tag">COPY tbl_testcsv(rno)
TO 'E:\dbrnd.com\Postwork\testcsv.csv'
WITH DELIMITER ','
CSV HEADER;</pre><p>
</p><pre class="crayon-plain-tag">COPY (SELECT rno,name FROM tbl_testcsv WHERE rno=8)
TO 'E:\dbrnd.com\Postwork\testcsv.csv'
WITH DELIMITER ','
CSV HEADER;</pre><p>
<p>This is a full detailed example of Postgres COPY command, please test this sample and let me know for further assistance.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
