Using MySql query, is it possible to create a database with a date in the title?

That is, for example, I want to call the user(24-11-16) database user(24-11-16) Something like this.

That is, the query will look like this.

 CREATE DATABASE 'users(CURDATE())' 
  • And what is it for? In fact, the date in the name of the table is an anti-pattern. - fens Nov.
  • I did not see that we are talking about the name of the database, in this version it is even worse. - fens
  • @fens looking for a way to copy my current database by adding a date - Yevgeniy Bagackiy

1 answer 1

You can create this way, the idea is taken from here :

 -- нужно заменить все тире из даты, так как -- они запрещены в названии базы данных SET @db_create_query = CONCAT('CREATE DATABASE', ' ', 'user_', REPLACE(CURDATE(), '-', '_')); PREPARE stmt_create FROM @db_create_query; EXECUTE stmt_create; DEALLOCATE PREPARE stmt_create;