Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (2.5k points)
recategorized by
Could someone tell me how to quickly rename a SQL database and change the schema name?

1 Answer

0 votes
by (7.2k points)

To quickly rename a mysql database you need to  create the new empty database, then rename each table in turn into the new database:

 

RENAME TABLE old_db.table TO new_db.table;

 

After executing the above command then you will need to adjust the permissions after that.:

 

mysql -u username -ppassword old_db -sNe 

 

'show tables' | while read table; \ 

    do mysql -u username -ppassword -sNe "rename table old_db.$table to new_db.$table"; done

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 6, 2019 in SQL by Tech4ever (20.3k points)

Browse Categories

...