MySQL - RENAME THE DATABASE - Asked By poodesh waran on 28-Oct-10 02:07 AM

HOW TO RANAME DATABASE;


I tried to rename the database esic into myesic...
Anurag replied to poodesh waran on 28-Oct-10 02:14 AM

Try this:
EXEC sp_renamedb 'oldName', 'newName'

This command works for both SQL Server 2000 and SQL Server 2005, but this feature will not be supported in future versions of SQL Server. The new command that should be used for SQL Serer 2005 and beyond is:

ALTER DATABASE oldName MODIFY NAME = newName
or
If you are using SQL Server Management Studio, right click on the database name and select the new option "rename". This did not exist in SQL Server 2000, but if you use Management Studio to manage your SQL Server 2000 server you can take advantage of this option for your SQL Server 2000 instances.

Rohan Dave replied to poodesh waran on 28-Oct-10 02:18 AM
have you tried below command to rename the database ?

RENAME DataBase oldname To newname
Reena Jain replied to poodesh waran on 28-Oct-10 02:21 AM
hi,

try this

use ALTER DATABASE dbname UPGRADE DATA DIRECTORY NAME
or this
mysqldump old_database -p | mysql -D new_database -p


hope this will help you
undhad ashwin replied to poodesh waran on 28-Oct-10 02:22 AM
try below statement

First u open sql server then after create new query then after copy paste below code

EXEC sp_renamedb 'oldname', 'newName'

then key press f5

if any issue then replay
Venkat K replied to poodesh waran on 28-Oct-10 02:25 AM
sp_rename is for sql server i think.
If you are getting any error when using rename in mysql you can use the following code to rename an existing database:
mysql -p
<enter password>
create database new_database;
quit


mysqldump old_database -p | mysql -D new_database -p
<enter password>



THanks
Anoop S replied to poodesh waran on 28-Oct-10 02:42 AM
There are a few ways of doing this.

Option 1

Use the following T-SQL: command to make the database name change.

EXEC sp_renamedb 'oldName', 'newName'

This command works for both SQL Server 2000 and SQL Server 2005, but this feature will not be supported in future versions of SQL Server. The new command that should be used for SQL Serer 2005 and beyond is:

ALTER DATABASE oldName MODIFY NAME = newName

Option 2

If you are using SQL Server Management Studio, right click on the database name and select the new option "rename". This did not exist in SQL Server 2000, but if you use Management Studio to manage your SQL Server 2000 server you can take advantage of this option for your SQL Server 2000 instances.

Option 3

Use the detach and attach feature of SQL Server to detach the database first and when you reattach the database you give the database a different name. This
Anoop S replied to poodesh waran on 28-Oct-10 02:42 AM
There are a few ways of doing this.

Option 1

Use the following T-SQL: command to make the database name change.

EXEC sp_renamedb 'oldName', 'newName'

This command works for both SQL Server 2000 and SQL Server 2005, but this feature will not be supported in future versions of SQL Server. The new command that should be used for SQL Serer 2005 and beyond is:

ALTER DATABASE oldName MODIFY NAME = newName

Option 2

If you are using SQL Server Management Studio, right click on the database name and select the new option "rename". This did not exist in SQL Server 2000, but if you use Management Studio to manage your SQL Server 2000 server you can take advantage of this option for your SQL Server 2000 instances.

Option 3

Use the detach and attach feature of SQL Server to detach the database first and when you reattach the database you give the database a different name.
pradeep joshi replied to poodesh waran on 12-Jan-11 04:47 AM


        Hi,


       Rename a Database

                    
You can rename the database if you have access to the directory in which MySQL stores its databases. For default MySQL installations this is usually in the Data directory under the directory where MySQL was installed. Locate the name of the database you want to rename under the Data directory and rename it.


Note:
You must stop MySQL before you can rename the database


   For example i am using wamp server ,so in this situation my all database directory stored in the following path

     C:\wamp\bin\mysql\mysql5.1.32\data\