<?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>COPY &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/copy/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>Tue, 13 Feb 2018 18:30:13 +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>PostgreSQL: Create a Copy of Table or Create a Duplicate Table</title>
		<link>https://www.dbrnd.com/2017/12/postgresql-create-a-copy-of-table-or-create-a-duplicate-table/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 02 Dec 2017 16:16:35 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[COPY]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6720</guid>

					<description><![CDATA[In the previous post, I copied table data into another table. In this post, I am creating a Copy of Table from another table of PostgreSQL. For creating a duplicate table, we have two options like SELECT INTO and CREATE TABLE AS. Check the below example: Create a sample table with data: [crayon-6aa1b6fe3ff50809105443/] Create tab_B [&#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%2F2017%2F12%2Fpostgresql-create-a-copy-of-table-or-create-a-duplicate-table%2F&amp;linkname=PostgreSQL%3A%20Create%20a%20Copy%20of%20Table%20or%20Create%20a%20Duplicate%20Table" 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%2F2017%2F12%2Fpostgresql-create-a-copy-of-table-or-create-a-duplicate-table%2F&amp;linkname=PostgreSQL%3A%20Create%20a%20Copy%20of%20Table%20or%20Create%20a%20Duplicate%20Table" 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%2F2017%2F12%2Fpostgresql-create-a-copy-of-table-or-create-a-duplicate-table%2F&amp;linkname=PostgreSQL%3A%20Create%20a%20Copy%20of%20Table%20or%20Create%20a%20Duplicate%20Table" 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%2F2017%2F12%2Fpostgresql-create-a-copy-of-table-or-create-a-duplicate-table%2F&amp;linkname=PostgreSQL%3A%20Create%20a%20Copy%20of%20Table%20or%20Create%20a%20Duplicate%20Table" 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%2F2017%2F12%2Fpostgresql-create-a-copy-of-table-or-create-a-duplicate-table%2F&amp;linkname=PostgreSQL%3A%20Create%20a%20Copy%20of%20Table%20or%20Create%20a%20Duplicate%20Table" 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%2F2017%2F12%2Fpostgresql-create-a-copy-of-table-or-create-a-duplicate-table%2F&amp;linkname=PostgreSQL%3A%20Create%20a%20Copy%20of%20Table%20or%20Create%20a%20Duplicate%20Table" 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%2F2017%2F12%2Fpostgresql-create-a-copy-of-table-or-create-a-duplicate-table%2F&#038;title=PostgreSQL%3A%20Create%20a%20Copy%20of%20Table%20or%20Create%20a%20Duplicate%20Table" data-a2a-url="https://www.dbrnd.com/2017/12/postgresql-create-a-copy-of-table-or-create-a-duplicate-table/" data-a2a-title="PostgreSQL: Create a Copy of Table or Create a Duplicate Table"></a></p><p>In the previous post, I copied table data into another table.<br />
In this post, I am creating a Copy of Table from another table of PostgreSQL. </p>
<p>For creating a duplicate table, we have two options like SELECT INTO and CREATE TABLE AS.</p>
<p>Check the below example:</p>
<p><strong>Create a sample table with data:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_A
(ID INT);

INSERT INTO tbl_A
VALUES
(1),(2),(3);</pre> </p>
<p><strong>Create tab_B as a duplicate table:</strong></p>
<p><strong>Using SELECT INTO:</strong></p>
<pre class="crayon-plain-tag">SELECT * INTO tbl_B FROM tbl_A;</pre> </p>
<p><strong>Using CREATE TABLE AS:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_B AS
SELECT *FROM tbl_A;</pre> </p>
<p><strong>Check the result:</strong></p>
<pre class="crayon-plain-tag">SELECT * FROM tbl_B;

id
--------
1
2
3</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PostgreSQL: Copy Table Data from another Table (INSERT INTO SELECT)</title>
		<link>https://www.dbrnd.com/2017/12/postgresql-copy-table-data-from-another-table-insert-into-select/</link>
					<comments>https://www.dbrnd.com/2017/12/postgresql-copy-table-data-from-another-table-insert-into-select/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 01 Dec 2017 16:16:54 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[COPY]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6718</guid>

					<description><![CDATA[In this post, I am sharing a demonstration on how to copy data from one table to another table using INSERT INTO SELECT in PostgreSQL. This article may help the beginner of PostgreSQL, because moving or copying data within the database which is the ubiquitous task. Use INSERT INTO SELECT statement, for this exercise: Create [&#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%2F2017%2F12%2Fpostgresql-copy-table-data-from-another-table-insert-into-select%2F&amp;linkname=PostgreSQL%3A%20Copy%20Table%20Data%20from%20another%20Table%20%28INSERT%20INTO%20SELECT%29" 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%2F2017%2F12%2Fpostgresql-copy-table-data-from-another-table-insert-into-select%2F&amp;linkname=PostgreSQL%3A%20Copy%20Table%20Data%20from%20another%20Table%20%28INSERT%20INTO%20SELECT%29" 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%2F2017%2F12%2Fpostgresql-copy-table-data-from-another-table-insert-into-select%2F&amp;linkname=PostgreSQL%3A%20Copy%20Table%20Data%20from%20another%20Table%20%28INSERT%20INTO%20SELECT%29" 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%2F2017%2F12%2Fpostgresql-copy-table-data-from-another-table-insert-into-select%2F&amp;linkname=PostgreSQL%3A%20Copy%20Table%20Data%20from%20another%20Table%20%28INSERT%20INTO%20SELECT%29" 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%2F2017%2F12%2Fpostgresql-copy-table-data-from-another-table-insert-into-select%2F&amp;linkname=PostgreSQL%3A%20Copy%20Table%20Data%20from%20another%20Table%20%28INSERT%20INTO%20SELECT%29" 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%2F2017%2F12%2Fpostgresql-copy-table-data-from-another-table-insert-into-select%2F&amp;linkname=PostgreSQL%3A%20Copy%20Table%20Data%20from%20another%20Table%20%28INSERT%20INTO%20SELECT%29" 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%2F2017%2F12%2Fpostgresql-copy-table-data-from-another-table-insert-into-select%2F&#038;title=PostgreSQL%3A%20Copy%20Table%20Data%20from%20another%20Table%20%28INSERT%20INTO%20SELECT%29" data-a2a-url="https://www.dbrnd.com/2017/12/postgresql-copy-table-data-from-another-table-insert-into-select/" data-a2a-title="PostgreSQL: Copy Table Data from another Table (INSERT INTO SELECT)"></a></p><p>In this post, I am sharing a demonstration on how to copy data from one table to another table using INSERT INTO SELECT in PostgreSQL. </p>
<p>This article may help the beginner of PostgreSQL, because moving or copying data within the database which is the ubiquitous task. </p>
<p>Use INSERT INTO SELECT statement, for this exercise:</p>
<p><strong>Create two sample tables:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_A
(ID INT);

CREATE TABLE tbl_B
(ID INT);</pre> </p>
<p><strong>Insert data into tbl_A:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO tbl_A
VALUES
(1),(2),(3);</pre> </p>
<p><strong>Copy data into tbl_B:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO tbl_B
SELECT *FROM tbl_A;</pre> </p>
<p><strong>Check the result:</strong></p>
<pre class="crayon-plain-tag">SELECT *FROM tbl_B;

id
--------
1
2
3</pre> </p>
<p><strong>Don&#8217;t try a below option:</strong></p>
<pre class="crayon-plain-tag">SELECT * INTO tbl_B FROM tbl_A;

********** Error **********
ERROR: relation "tbl_b" already exists
SQL state: 42P07</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/12/postgresql-copy-table-data-from-another-table-insert-into-select/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: ERROR &#8211; must be superuser to COPY to or from a file</title>
		<link>https://www.dbrnd.com/2017/07/postgresql-error-must-be-superuser-to-copy-to-or-from-a-file/</link>
					<comments>https://www.dbrnd.com/2017/07/postgresql-error-must-be-superuser-to-copy-to-or-from-a-file/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 08 Jul 2017 16:16:51 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[COPY]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[superuser]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5587</guid>

					<description><![CDATA[You are getting above error message because an only superuser can execute the COPY command in PostgreSQL. Currently, I am working with ETL team, and we are managing the massive size of Data warehouse. In the ETL project, database developers may require using COPY command. But unfortunately, they are getting below error. [crayon-6aa1b6fe402eb753409267/] The solution: [&#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%2F2017%2F07%2Fpostgresql-error-must-be-superuser-to-copy-to-or-from-a-file%2F&amp;linkname=PostgreSQL%3A%20ERROR%20%E2%80%93%20must%20be%20superuser%20to%20COPY%20to%20or%20from%20a%20file" 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%2F2017%2F07%2Fpostgresql-error-must-be-superuser-to-copy-to-or-from-a-file%2F&amp;linkname=PostgreSQL%3A%20ERROR%20%E2%80%93%20must%20be%20superuser%20to%20COPY%20to%20or%20from%20a%20file" 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%2F2017%2F07%2Fpostgresql-error-must-be-superuser-to-copy-to-or-from-a-file%2F&amp;linkname=PostgreSQL%3A%20ERROR%20%E2%80%93%20must%20be%20superuser%20to%20COPY%20to%20or%20from%20a%20file" 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%2F2017%2F07%2Fpostgresql-error-must-be-superuser-to-copy-to-or-from-a-file%2F&amp;linkname=PostgreSQL%3A%20ERROR%20%E2%80%93%20must%20be%20superuser%20to%20COPY%20to%20or%20from%20a%20file" 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%2F2017%2F07%2Fpostgresql-error-must-be-superuser-to-copy-to-or-from-a-file%2F&amp;linkname=PostgreSQL%3A%20ERROR%20%E2%80%93%20must%20be%20superuser%20to%20COPY%20to%20or%20from%20a%20file" 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%2F2017%2F07%2Fpostgresql-error-must-be-superuser-to-copy-to-or-from-a-file%2F&amp;linkname=PostgreSQL%3A%20ERROR%20%E2%80%93%20must%20be%20superuser%20to%20COPY%20to%20or%20from%20a%20file" 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%2F2017%2F07%2Fpostgresql-error-must-be-superuser-to-copy-to-or-from-a-file%2F&#038;title=PostgreSQL%3A%20ERROR%20%E2%80%93%20must%20be%20superuser%20to%20COPY%20to%20or%20from%20a%20file" data-a2a-url="https://www.dbrnd.com/2017/07/postgresql-error-must-be-superuser-to-copy-to-or-from-a-file/" data-a2a-title="PostgreSQL: ERROR – must be superuser to COPY to or from a file"></a></p><p>You are getting above error message because an only superuser can execute the COPY command in PostgreSQL.</p>
<p>Currently, I am working with ETL team, and we are managing the massive size of Data warehouse. </p>
<p>In the ETL project, database developers may require using COPY command. But unfortunately, they are getting below error.</p>
<pre class="crayon-plain-tag">ERROR:  must be superuser to COPY to or from a file
HINT:  Anyone can COPY to stdout or from stdin. psql's \copy command also works for anyone.</pre> </p>
<p><strong>The solution:</strong><br />
The superuser can create a wrapper function and can assign to the public.</p>
<p><strong>Script to create a wrapper function:</strong></p>
<pre class="crayon-plain-tag">create or replace function copy_for_all(tablename text, filepath text)
returns void
security definer
as
$$
declare
begin
	execute 'copy ' || tablename || ' from ''' || filepath || '''';
end;
$$ language plpgsql;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/07/postgresql-error-must-be-superuser-to-copy-to-or-from-a-file/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server: Copy Table Data from one Database to another Database</title>
		<link>https://www.dbrnd.com/2016/09/sql-server-copy-table-data-from-one-database-to-another-database/</link>
					<comments>https://www.dbrnd.com/2016/09/sql-server-copy-table-data-from-one-database-to-another-database/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 28 Sep 2016 16:16:52 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[COPY]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2083</guid>

					<description><![CDATA[One of the junior database developer of our team asked me one question that how can we copy table data from one database to another database in SQL Server. This post is dedicated to all junior database developer and sharing full demonstration to copy table data from one database to another database. Create a First [&#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%2F2016%2F09%2Fsql-server-copy-table-data-from-one-database-to-another-database%2F&amp;linkname=SQL%20Server%3A%20Copy%20Table%20Data%20from%20one%20Database%20to%20another%20Database" 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%2F2016%2F09%2Fsql-server-copy-table-data-from-one-database-to-another-database%2F&amp;linkname=SQL%20Server%3A%20Copy%20Table%20Data%20from%20one%20Database%20to%20another%20Database" 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%2F2016%2F09%2Fsql-server-copy-table-data-from-one-database-to-another-database%2F&amp;linkname=SQL%20Server%3A%20Copy%20Table%20Data%20from%20one%20Database%20to%20another%20Database" 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%2F2016%2F09%2Fsql-server-copy-table-data-from-one-database-to-another-database%2F&amp;linkname=SQL%20Server%3A%20Copy%20Table%20Data%20from%20one%20Database%20to%20another%20Database" 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%2F2016%2F09%2Fsql-server-copy-table-data-from-one-database-to-another-database%2F&amp;linkname=SQL%20Server%3A%20Copy%20Table%20Data%20from%20one%20Database%20to%20another%20Database" 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%2F2016%2F09%2Fsql-server-copy-table-data-from-one-database-to-another-database%2F&amp;linkname=SQL%20Server%3A%20Copy%20Table%20Data%20from%20one%20Database%20to%20another%20Database" 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%2F2016%2F09%2Fsql-server-copy-table-data-from-one-database-to-another-database%2F&#038;title=SQL%20Server%3A%20Copy%20Table%20Data%20from%20one%20Database%20to%20another%20Database" data-a2a-url="https://www.dbrnd.com/2016/09/sql-server-copy-table-data-from-one-database-to-another-database/" data-a2a-title="SQL Server: Copy Table Data from one Database to another Database"></a></p><p>One of the junior database developer of our team asked me one question that how can we copy table data from one database to another database in SQL Server. </p>
<p>This post is dedicated to all junior database developer and sharing full demonstration to copy table data from one database to another database. </p>
<p><strong>Create a First Database with Sample Table:</strong></p>
<pre class="crayon-plain-tag">CREATE DATABASE Database_A;
GO

CREATE TABLE [Database_A].[dbo].[tbl_Employee]
(
	EmpID INTEGER IDENTITY(1,1)
	,EmpName VARCHAR(255)
	,Gender CHAR(1)
	,DOB DATETIME
	,CONSTRAINT pk_tbl_Employee_EmpID PRIMARY KEY(EmpID)
)
GO</pre> </p>
<p><strong>Create a Second Database with Sample Table:</strong></p>
<pre class="crayon-plain-tag">CREATE DATABASE Database_B;
GO

CREATE TABLE [Database_B].[dbo].[tbl_Employee]
(
	EmpID INTEGER IDENTITY(1,1)
	,EmpName VARCHAR(255)
	,Gender CHAR(1)
	,DOB DATETIME
	,CONSTRAINT pk_tbl_Employee_EmpID PRIMARY KEY(EmpID)
)
GO</pre> </p>
<p><strong>Insert sample data into First Database&#8217;s Table:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO [Database_A].[dbo].[tbl_Employee]
(EmpName,Gender,DOB)
VALUES
('Anvesh','M','19880126')
,('Roy','M','19930214')
,('Jenny','F','19920320')
,('Martin','M','19850616')
GO</pre> </p>
<p><strong>Copy First Database&#8217;s Table Data into another Database:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO [Database_B].[dbo].[tbl_Employee]
(EmpName,Gender,DOB)
SELECT 
	[EmpName]
	,[Gender]
	,[DOB]
FROM [Database_A].[dbo].[tbl_Employee]
GO</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/09/sql-server-copy-table-data-from-one-database-to-another-database/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: File System Level Backup to just Copy DATA Directory</title>
		<link>https://www.dbrnd.com/2016/09/postgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 12 Sep 2016 19:35:10 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[COPY]]></category>
		<category><![CDATA[copy postgres data directory]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[File System Level Backup]]></category>
		<category><![CDATA[paste]]></category>
		<category><![CDATA[performance]]></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=3637</guid>

					<description><![CDATA[For reading this article title, Please do not surprise. Yes, this is possible in PostgreSQL. We can simply copy the PostgreSQL DATA Directory and can use as a full PostgreSQL Database Server backup. The File System Level backup is not always recommended, but we can use this backup method in certain condition. In our organization, [&#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%2F2016%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&amp;linkname=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" 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%2F2016%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&amp;linkname=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" 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%2F2016%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&amp;linkname=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" 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%2F2016%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&amp;linkname=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" 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%2F2016%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&amp;linkname=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" 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%2F2016%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&amp;linkname=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" 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%2F2016%2F09%2Fpostgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore%2F&#038;title=PostgreSQL%3A%20File%20System%20Level%20Backup%20to%20just%20Copy%20DATA%20Directory" data-a2a-url="https://www.dbrnd.com/2016/09/postgresql-file-system-level-backup-to-just-copy-data-directory-fast-postgres-cluster-backup-restore/" data-a2a-title="PostgreSQL: File System Level Backup to just Copy DATA Directory"></a></p><p><em>For reading this article title, Please do not surprise.<br />
Yes, this is possible in PostgreSQL. </em></p>
<p>We can simply copy the PostgreSQL DATA Directory and can use as a full PostgreSQL Database Server backup.</p>
<p><img fetchpriority="high" decoding="async" class="alignleft wp-image-3639 size-full" title="postgres files ystem backup" src="https://www.dbrnd.com/wp-content/uploads/2016/09/PostgresFileSystemBackup.png" alt="postgres files ystem backup" width="256" height="256" srcset="https://www.dbrnd.com/wp-content/uploads/2016/09/PostgresFileSystemBackup.png 256w, https://www.dbrnd.com/wp-content/uploads/2016/09/PostgresFileSystemBackup-150x150.png 150w" sizes="(max-width: 256px) 100vw, 256px" /></p>
<p><strong>The File System Level backup is not always recommended, but we can use this backup method in certain condition. </strong></p>
<p>In our organization, I am managing PostgreSQL backup using two approaches.</p>
<blockquote><p>The First approach is a regular method for taking individual Database Backup using pgDump.</p></blockquote>
<blockquote><p>The Second approach is to take &#8220;frozen snapshot&#8221; of the PostgreSQL DATA directory. Our System Admin department is taking File System Level Backup of PostgreSQL.</p></blockquote>
<blockquote><p>Whenever I required new duplicate PostgreSQL server, I used this kind of file system backup of PostgreSQL.</p></blockquote>
<blockquote><p>It is faster than pgDump because It does not require any additional CPU I/O as full DATA directory already available on DISK.<br />
System Admin has to perform simple COPY and PASTE like any other file or folder.</p></blockquote>
<p><strong>Few Restrictions are:</strong></p>
<blockquote><p>The database server must be shut down in order to get a usable backup and disallowing all connections will not work.</p></blockquote>
<blockquote><p>It is impossible to restore only a table or few tables. A File system backups only work for complete backup and restoration of an entire database cluster.</p></blockquote>
<blockquote><p>If your data files and WAL log are on different disks, or if tablespaces are on different file systems, it might not be possible to use snapshot backup or file system level backup.</p></blockquote>
<blockquote><p>A file system backup will typically be larger than an SQL dump.</p></blockquote>
<blockquote><p>After restoring of file system backup, It requires to rebuild all your Database Indexes.(For improving the performance)</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
