在 MySQL 主服务器上创建不复制到从服务器的表

发布于 2024-12-02 14:39:21 字数 279 浏览 4 评论 0原文

我有一些脚本可以在 MySQL master 上创建一个表,用数据填充它,对数据进行一些处理,然后再次删除该表。

我不想将所有这些复制到奴隶身上,因为这是浪费时间。有没有办法告诉从站与此表无关,或者通过在 CREATE TABLE 语句本身中做一些巧妙的事情,或者通过设置一个配置命令来声明类似“不要复制任何以 'temp_' 开头的表” “(表名是动态的,以允许多个用户,但它始终以 temp_ 开头)。

当然,使用合适的临时表是完美的,但不幸的是我需要在一个查询中多次引用该表,而 MySQL 不允许这样做。

I've got bit of script that creates a table on a MySQL master, fills 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情释 2024-12-09 14:39:21

有一个选项 为此,
但我不确定你会喜欢这个(需要重新启动)

告诉从属 SQL 线程不要复制任何更新指定表的语句,即使同一语句可能更新任何其他表。要指定忽略多个表,请多次使用此选项,每个表一次。

更多详细信息

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

只有影子陪我不离不弃 2024-12-09 14:39:21

您可以将该表放在另一个数据库中。

然后做这样的声明:

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

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
.....
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文