简体   繁体   中英

How to alter same table in multiple databases in MySQL

I have a set of database schemas, with each one having the same set of tables.

I want to alter a table by adding a column in each one of the schemas with a single command, instead of doing it for every schema separateley.

Is that possible?

This isn't quite identical to Querying multiple databases at once but it's similar. As in the linked question, you could write a procedure:

  1. Get the schema names from information_schema.tables
  2. Create your query template
  3. Loop over the schema names and for each schema sub the schema name in the query template

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM