开发者

CREATE TABLE on MySQL Master that does not replicate to the slaves

开发者 https://www.devze.com 2023-04-01 01:42 出处:网络
I\'ve got bit of script that creates a table on a MySQL master, fil开发者_C百科ls it with data, does some work on the data and then drops the table again.

I've got bit of script that creates a table on a MySQL master, fil开发者_C百科ls it with data, does some work on the data and then drops the table again.

I don't want all this to be replicated to the slaves, as it is a waste of time. Is there any way to tell the slave to have nothing to do with this table, either by doing something clever in the CREATE TABLE statement itself or by setting a config command that states something like "Don't replicate any table beginning with 'temp_'" (the table name is dynamic to allow for multiple users, but it always starts with temp_).

Of course, using a proper temporary table would be perfect, but unfortunately I need to reference the table multiple times in one query, which MySQL doesn't allow.


there is an option for this,
but i not sure you will prefer this (require restart)

Tells the slave SQL thread not to replicate any statement that updates the specified table, even if any other tables might be updated by the same statement. To specify more than one table to ignore, use this option multiple times, once for each table.

more details


You can put the table in another database.

And then do a statement like:

SELECT a.field1, b.field2 FROM table1 a
INNER JOIN db2.tablex b
.....
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号