Include new table in multiple Mysql databases at once

Asked

Viewed 86 times

1

I don’t know if it would be possible, but we took a system made in PHP/Mysql from which each client has its own database. But we are creating another tool for this system and of course, will have a new table in the databases. The problem is that this system, as stated before, has a total of 23 databases and each bank belongs to a registered customer in this system.

It is possible that when developing a new table, include it in all these databases at once through some SQL command or we will have to go from one in a database to install this new table?

  • you consider the possibility of doing this via script? if yes, I believe it is possible (with loop)

  • I didn’t quite understand the "include it in all these databases at once", if the bank is in each client, you will have to run a script or installer in each of the clients is not?

  • 1

    whereas the banks are on the same server, my idea is to load the names of the banks and re-run them by creating the new table. (I won’t be able to give an example now, if the comment doesn’t help and/or can’t resolve, later I try..)

  • Hello guys. That’s it. It’s on the same server. It has a reseller, where it has these registered clients. He took a resale just to include these clients. I can consider via script. At first I even thought of doing it via script, but I also thought that directly in SQL would have some way. But if it is via script, it is possible to bring the name of these databases or would have to put manually?

1 answer

1

Good morning, you can use the code below when you want to change database, before running the table creation script. You can do a sequence or a for.

USE DB_NomeBanco GO 
Select * from tabela
  • Hello Wellington, right, but is there any way to get the name of all the server databases automatically without me having to type one by one?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.