My Database name is SPM
and I want to change it to spm
(small letters).
I tried using
RENAME DATABASE SPM TO spm;
, but I am getting the following error message:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATABASE SPM to spm' at line 1
My server version: 5.0.45
Table and database names are stored on disk using the lettercase specified in the CREATE TABLE or CREATE DATABASE statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case-sensitive. This works only on file systems that are not case-sensitive!
To set the collation for the entire database, you can use: CREATE DATABASE test_database CHARACTER SET utf8 COLLATE utf8_general_cs; You can also change the collation on an existing database via ALTER DATABASE. (For more information see the MySQL Database Character Set and Collation manual entry.)
Yes, you can use the LOWER() or LCASE() from MySQL to convert a string to lowercase. Both methods can be used to convert the string into lowercase. lower('yourStringValue); Or you can use LCASE().
There is no database command to do it. You basically have to do it outside the database. Below are some references outlining possible solutions. It has been answered pretty good in this question
This is probably what it should look like in your case
mysqladmin create spm
mysqldump SPM | mysql spm
After you have verified that everything is in order you can drop the original database.
drop database SPM
References Rename database 1 / Rename database 2
[Note on "RENAME DATABASE" command: This statement was added in MySQL 5.1.7 but was found to be dangerous and was removed in MySQL 5.1.23.]
RENAME {DATABASE | SCHEMA} db_name TO new_db_name;
This statement was added in MySQL 5.1.7 but was found to be dangerous and was removed in MySQL 5.1.23. It was intended to enable upgrading pre-5.1 databases to use the encoding implemented in 5.1 for mapping database names to database directory names . However, use of this statement could result in loss of database contents, which is why it was removed. Do not use RENAME DATABASE
in earlier versions in which it is present.
To perform the task of upgrading database names with the new encoding, use ALTER DATABASE db_name UPGRADE DATA DIRECTORY NAME
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With