<?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>Rename Table &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/rename-table/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, 06 Jul 2018 20:27:23 +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: How to Swap Table or Rename the table in one transaction?</title>
		<link>https://www.dbrnd.com/2018/08/mysql-how-to-swap-table-or-rename-the-table-in-one-transaction/</link>
					<comments>https://www.dbrnd.com/2018/08/mysql-how-to-swap-table-or-rename-the-table-in-one-transaction/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 06 Aug 2018 16:16:24 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></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 Tuning]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[MySQL Tips and Tricks]]></category>
		<category><![CDATA[Rename Table]]></category>
		<category><![CDATA[swap table]]></category>
		<category><![CDATA[swap table in a transaction]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7696</guid>

					<description><![CDATA[In this post, I am sharing a command to swap the table in a MySQL Database. Recently, I got a requirement like a swap or rename the table, it should execute in a lock/transaction. People can access the table before or after the swapping only. In an ETL/Database work, we are creating a staging table [&#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%2F2018%2F08%2Fmysql-how-to-swap-table-or-rename-the-table-in-one-transaction%2F&amp;linkname=MySQL%3A%20How%20to%20Swap%20Table%20or%20Rename%20the%20table%20in%20one%20transaction%3F" 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%2F2018%2F08%2Fmysql-how-to-swap-table-or-rename-the-table-in-one-transaction%2F&amp;linkname=MySQL%3A%20How%20to%20Swap%20Table%20or%20Rename%20the%20table%20in%20one%20transaction%3F" 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%2F2018%2F08%2Fmysql-how-to-swap-table-or-rename-the-table-in-one-transaction%2F&amp;linkname=MySQL%3A%20How%20to%20Swap%20Table%20or%20Rename%20the%20table%20in%20one%20transaction%3F" 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%2F2018%2F08%2Fmysql-how-to-swap-table-or-rename-the-table-in-one-transaction%2F&amp;linkname=MySQL%3A%20How%20to%20Swap%20Table%20or%20Rename%20the%20table%20in%20one%20transaction%3F" 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%2F2018%2F08%2Fmysql-how-to-swap-table-or-rename-the-table-in-one-transaction%2F&amp;linkname=MySQL%3A%20How%20to%20Swap%20Table%20or%20Rename%20the%20table%20in%20one%20transaction%3F" 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%2F2018%2F08%2Fmysql-how-to-swap-table-or-rename-the-table-in-one-transaction%2F&amp;linkname=MySQL%3A%20How%20to%20Swap%20Table%20or%20Rename%20the%20table%20in%20one%20transaction%3F" 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%2F2018%2F08%2Fmysql-how-to-swap-table-or-rename-the-table-in-one-transaction%2F&#038;title=MySQL%3A%20How%20to%20Swap%20Table%20or%20Rename%20the%20table%20in%20one%20transaction%3F" data-a2a-url="https://www.dbrnd.com/2018/08/mysql-how-to-swap-table-or-rename-the-table-in-one-transaction/" data-a2a-title="MySQL: How to Swap Table or Rename the table in one transaction?"></a></p><p>In this post, I am sharing a command to swap the table in a MySQL Database. </p>
<p>Recently, I got a requirement like a swap or rename the table, it should execute in a lock/transaction. People can access the table before or after the swapping only. </p>
<p>In an ETL/Database work, we are creating a staging table for validation and later it requires to overwrite with an original table name. </p>
<p><strong>Below is a simple command, which you can use for this task:</strong><br />
Here, DBRND_Original is an existing table and DBRND_Original_New is my staging table.<br />
Now, I am swapping the table using one rename command which performs whole swapping operation in one transaction.</p>
<pre class="crayon-plain-tag">RENAME TABLE DBRND_Original TO DBRND_Original_Backup, DBRND_Original_New To DBRND_Original;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2018/08/mysql-how-to-swap-table-or-rename-the-table-in-one-transaction/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server: Script to rename all Tables of a Database</title>
		<link>https://www.dbrnd.com/2018/02/sql-server-script-to-rename-all-tables-of-a-database/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 11 Feb 2018 16:16:25 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Rename Table]]></category>
		<category><![CDATA[sp_executesql]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7075</guid>

					<description><![CDATA[<div><img width="256" height="256" src="https://www.dbrnd.com/wp-content/uploads/2018/01/Rename.png" class="attachment-post-image size-post-image wp-post-image" alt="" decoding="async" fetchpriority="high" srcset="https://www.dbrnd.com/wp-content/uploads/2018/01/Rename.png 256w, https://www.dbrnd.com/wp-content/uploads/2018/01/Rename-150x150.png 150w" sizes="(max-width: 256px) 100vw, 256px" /></div>In this post, I am sharing a T-SQL script for renaming multiple tables to a SQL Server Database. Recently, I was doing test migration for more than 100 tables. I planned to rename those tables before migration so later I can rollback those tables. SQL Server: Script to rename Database Name, Table Name, Column Name [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="256" height="256" src="https://www.dbrnd.com/wp-content/uploads/2018/01/Rename.png" class="attachment-post-image size-post-image wp-post-image" alt="" decoding="async" srcset="https://www.dbrnd.com/wp-content/uploads/2018/01/Rename.png 256w, https://www.dbrnd.com/wp-content/uploads/2018/01/Rename-150x150.png 150w" sizes="(max-width: 256px) 100vw, 256px" /></div><p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F02%2Fsql-server-script-to-rename-all-tables-of-a-database%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20rename%20all%20Tables%20of%20a%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%2F2018%2F02%2Fsql-server-script-to-rename-all-tables-of-a-database%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20rename%20all%20Tables%20of%20a%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%2F2018%2F02%2Fsql-server-script-to-rename-all-tables-of-a-database%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20rename%20all%20Tables%20of%20a%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%2F2018%2F02%2Fsql-server-script-to-rename-all-tables-of-a-database%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20rename%20all%20Tables%20of%20a%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%2F2018%2F02%2Fsql-server-script-to-rename-all-tables-of-a-database%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20rename%20all%20Tables%20of%20a%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%2F2018%2F02%2Fsql-server-script-to-rename-all-tables-of-a-database%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20rename%20all%20Tables%20of%20a%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%2F2018%2F02%2Fsql-server-script-to-rename-all-tables-of-a-database%2F&#038;title=SQL%20Server%3A%20Script%20to%20rename%20all%20Tables%20of%20a%20Database" data-a2a-url="https://www.dbrnd.com/2018/02/sql-server-script-to-rename-all-tables-of-a-database/" data-a2a-title="SQL Server: Script to rename all Tables of a Database"></a></p><p>In this post, I am sharing a T-SQL script for renaming multiple tables to a SQL Server Database.</p>
<p>Recently, I was doing test migration for more than 100 tables. I planned to rename those tables before migration so later I can rollback those tables.   </p>
<blockquote class="wp-embedded-content" data-secret="2NPrIwf0m6"><p><a href="https://www.dbrnd.com/2016/11/sql-server-script-to-rename-database-name-table-name-column-name/">SQL Server: Script to rename Database Name, Table Name, Column Name</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/11/sql-server-script-to-rename-database-name-table-name-column-name/embed/#?secret=2NPrIwf0m6" data-secret="2NPrIwf0m6" width="600" height="338" title="&#8220;SQL Server: Script to rename Database Name, Table Name, Column Name&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>I used below script for renaming multiple tables of a database where I am adding &#8220;_backup&#8221; in the table name. </p>
<pre class="crayon-plain-tag">DECLARE @SQL NVARCHAR(max)=''

SELECT @SQL += 'exec sp_rename ' + NAME + ',' + NAME + '_backup '
FROM   sys.tables
WHERE  NAME IN ( 'table_one', 'table_two', 'table_three')

EXEC sp_executesql @SQL</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>MySQL: Simplest way to move your InnoDB table from one Database to another Database</title>
		<link>https://www.dbrnd.com/2017/04/mysql-simplest-way-to-move-your-innodb-table-from-one-database-to-another-database-move-ibd-file-frm-file/</link>
					<comments>https://www.dbrnd.com/2017/04/mysql-simplest-way-to-move-your-innodb-table-from-one-database-to-another-database-move-ibd-file-frm-file/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 02 Apr 2017 16:16:04 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[.frm file]]></category>
		<category><![CDATA[.ibd file]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[InnoDB Move Table]]></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>
		<category><![CDATA[Rename Table]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3767</guid>

					<description><![CDATA[In this post, I am sharing a simple solution to move your InnoDB table from one database to another database in MySQL. Before a few days ago, one of my team members was looking for this solution, and I found that many of Database Administrators do not know about this simple solution. The solution is, [&#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%2F04%2Fmysql-simplest-way-to-move-your-innodb-table-from-one-database-to-another-database-move-ibd-file-frm-file%2F&amp;linkname=MySQL%3A%20Simplest%20way%20to%20move%20your%20InnoDB%20table%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%2F2017%2F04%2Fmysql-simplest-way-to-move-your-innodb-table-from-one-database-to-another-database-move-ibd-file-frm-file%2F&amp;linkname=MySQL%3A%20Simplest%20way%20to%20move%20your%20InnoDB%20table%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%2F2017%2F04%2Fmysql-simplest-way-to-move-your-innodb-table-from-one-database-to-another-database-move-ibd-file-frm-file%2F&amp;linkname=MySQL%3A%20Simplest%20way%20to%20move%20your%20InnoDB%20table%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%2F2017%2F04%2Fmysql-simplest-way-to-move-your-innodb-table-from-one-database-to-another-database-move-ibd-file-frm-file%2F&amp;linkname=MySQL%3A%20Simplest%20way%20to%20move%20your%20InnoDB%20table%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%2F2017%2F04%2Fmysql-simplest-way-to-move-your-innodb-table-from-one-database-to-another-database-move-ibd-file-frm-file%2F&amp;linkname=MySQL%3A%20Simplest%20way%20to%20move%20your%20InnoDB%20table%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%2F2017%2F04%2Fmysql-simplest-way-to-move-your-innodb-table-from-one-database-to-another-database-move-ibd-file-frm-file%2F&amp;linkname=MySQL%3A%20Simplest%20way%20to%20move%20your%20InnoDB%20table%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%2F2017%2F04%2Fmysql-simplest-way-to-move-your-innodb-table-from-one-database-to-another-database-move-ibd-file-frm-file%2F&#038;title=MySQL%3A%20Simplest%20way%20to%20move%20your%20InnoDB%20table%20from%20one%20Database%20to%20another%20Database" data-a2a-url="https://www.dbrnd.com/2017/04/mysql-simplest-way-to-move-your-innodb-table-from-one-database-to-another-database-move-ibd-file-frm-file/" data-a2a-title="MySQL: Simplest way to move your InnoDB table from one Database to another Database"></a></p><p>In this post, I am sharing a simple solution to move your InnoDB table from one database to another database in MySQL.</p>
<blockquote><p>Before a few days ago, one of my team members was looking for this solution, and I found that many of Database Administrators do not know about this simple solution.<br />
The solution is, we have to just rename the table name by specifying a database name. </p></blockquote>
<blockquote><p>The MySQL InnoDB engine has two types of tablespaces, one is a shared table space and second is an individual tablespace for each table.<br />
This solution works for both the types of tablespaces. </p></blockquote>
<p><strong>Important Note:</strong> ibdata1 file or all .ibd file should be in one MySQL Data Directory at the same location.</p>
<p>After this demonstration, you can visit InnoDB Tablespace related articles. </p>
<p><strong>Create TWO Sample Databases:</strong></p>
<pre class="crayon-plain-tag">CREATE DATABASE ABC;
CREATE DATABASE XYZ;</pre> </p>
<p><strong>Create a sample table in database ABC:</strong></p>
<pre class="crayon-plain-tag">USE ABC;

CREATE TABLE tbl_Students
(
	RNO INT 
	,StudName VARCHAR(20)
);

INSERT INTO tbl_Students
VALUES 
(1,'Anvesh'),(2,'Neevan')
,(3,'Jeeny'),(4,'Roy');</pre> </p>
<p><strong>Simplest way to move tbl_Students from database ABC to XYZ:</strong></p>
<pre class="crayon-plain-tag">RENAME TABLE ABC.tbl_Students TO XYZ.tbl_Students;</pre> </p>
<p><strong>Check tbl_Students in XYZ database:</strong></p>
<pre class="crayon-plain-tag">USE XYZ;

SELECT *FROM tbl_Students;
+------+----------+
| RNO  | StudName |
+------+----------+
|    1 | Anvesh   |
|    2 | Neevan   |
|    3 | Jeeny    |
|    4 | Roy      |
+------+----------+</pre> </p>
<blockquote data-secret="2T366N3Jfm" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/09/mysql-why-innodb-engine-stores-all-databases-in-one-file-ibdata1/">MySQL: Why InnoDB Engine stores all databases in one file (ibdata1)?</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/09/mysql-why-innodb-engine-stores-all-databases-in-one-file-ibdata1/embed/#?secret=2T366N3Jfm" data-secret="2T366N3Jfm" width="600" height="338" title="&#8220;MySQL: Why InnoDB Engine stores all databases in one file (ibdata1)?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote data-secret="BVWsETOBrf" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/09/mysql-the-truth-about-innodb-file-per-table-tablespaces/">MySQL: The Truth about InnoDB File Per Table Tablespaces</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/09/mysql-the-truth-about-innodb-file-per-table-tablespaces/embed/#?secret=BVWsETOBrf" data-secret="BVWsETOBrf" width="600" height="338" title="&#8220;MySQL: The Truth about InnoDB File Per Table Tablespaces&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/04/mysql-simplest-way-to-move-your-innodb-table-from-one-database-to-another-database-move-ibd-file-frm-file/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
