Background story: our development team went to client site and had to restore dump which they brought with them. Client already made database, and our requirement is that database have specific name, because of triggers which writes to another database
Task: make script for changing database name as simple as possible in order to make people on field life easier.
Solution: Such script is made which checks all necessary things, and if everything is OK, proceeds on changing database name. Script is in this file.