如何在 RDS 副本实例中创建临时表

How to create temporary tables in a RDS replica instance

我的开发人员要求我能够创建 Temporary Tables

但是他们配置的连接连接到 RDS Read Replica Instance

如何设置权限以便他们的连接可以在该实例中创建临时表?

使用具有 'ALL' 权限 的用户与您的 master RDS 实例建立连接并创建一个 tmp 数据库作为临时表的存储点:

create database if not exists tmp;

SELECTCREATE TEMPORARY TABLES 分配给您的副本用户的连接:

grant SELECT, CREATE TEMPORARY TABLES ON tmp.* TO youruser@'%';

现在,您可以通过副本连接操作临时表:

create temporary table tmp.my_temporary_table
  select 
    mt.id
  from my_databaes.my_table as mt
  limit 10;

select * from tmp.my_temporary_table;

drop temporary table tmp.my_temporary_table;