I was doing this process in a same server but different databases.
- Insert data into a table in dev database
- Check the data
- If the data is fine, insert into a same table in prd database
but now I separated those databases into different servers. development server, production server. I didn't want to edit so many existing queries, so I created federated tables that connected to the production server. but every time when I alter production tables.. I had to recreate federated tables again.
Is there a way to not recreate federated tables every time when I alter the original table?
Can I make a linked database?
This answer is assuming you have federatedX plugin available instead or in addition to federated.
You should try the following :
If this is the case, the engine federatedx (used only for the plugin name, the engine name in DDL statements is still federated) you can use the following statements :
of course, you have to replace the values using your remote server ip, user, password, database, etc.
Later on, if anything change in your remote server properties, you just have to alter the server (no alter table are required anymore).
Creating your local table like this will activate federatedx discovery mode, making your local table structure as the exact copy of the remote one.
What if your remote table structure change : unfortunately it's not automatic (the federatedx discovery mode is activated one time when the local table is created and it's not kept up to date), however, it's quiet easy as you just have to re-create your local table the same way
And you're done !
The drawback of this local tables declaration method, is to require your local tables' names to be exactly the same as remote ones
If you absolutely need different names for your local and remote tables, you can use the "old" connection syntax used in the create table (finishing with <remote_db_name>/<remote_table_name>)