RENAME DATABASE
RENAME DATABASE is a SQL statement in the Administration category. SQL Server/MySQL: renames a database. In most systems, it requires exclusive access. The syntax is ALTER DATABASE old_name MODIFY NAME = new_name;. It returns database renamed. A typical example: -- SQL Server: ALTER DATABASE old_name SET SINGLE_USER WITH ROLLBACK IMMEDIATE; ALTER DATABASE old_name MODIFY NAME = new_name; ALTER DATABASE new_name SET MULTI_USER; -- MySQL: -- No direct RENAME DATABASE. Use mysqldump or create new + drop old -- PostgreSQL: ALTER DATABASE old_name RENAME TO new_name; -- (Disconnect all sessions first) A close relative is CREATE USER, which creates a new database user account. A close relative is GRANT, which grants specific privileges (SELECT, INSERT, UPDATE, DELETE, ALL) to a user on a database/table. A close relative is REVOKE, which removes previously granted privileges from a user. More about this category: Database administration — CREATE DATABASE, GRANT, REVOKE, SHOW, DESCRIBE.