sql - 如何运行存储在 Redshift 表中的 SQL 查询
问题描述
我想运行一个在 Redshift 表中存储为 varchar 的 SQL 查询。有没有办法达到同样的效果?这就是我想要的:
--if we have a text script like this
insert into schema_1.table_1 (id, script) values (1, 'select count(*) from
schema_2.table_2;');
--is there any way to run this script in SQL?
RunString(select script from schema_1.table_1 where id = 1);
该表如下所示:
___________________________________________
|Id|Query |
|--|--------------------------------------|
|1 |select count(*) from schema_2.table_2;|
-------------------------------------------
简而言之,我想运行上表中的查询。
解决方案
You might be able to achieve this by Creating Stored Procedures in Amazon Redshift.
I notice that that Supported PL/pgSQL Statements include:
Dynamic SQL
To generate dynamic commands that can involve different tables or different data types each time they are run from a PL/pgSQL stored procedure, use the
EXECUTE
statement.
EXECUTE command-string [ INTO target ];
推荐阅读
- ios - 运行 react-native run-ios 会启动应用程序但在启动后关闭,但通过 Xcode 可以完美运行
- xcode - Xcode 10.0 模拟器错误“Mach 错误 -308 - (ipc/mig) 服务器死亡”
- php - Codeigniter 图像未上传
- ssl - 启用 ssl 的 Jboss 远程处理
- c# - 即使文本框有数据,也会出现数据验证消息
- java - NumberFormatException - 如何解决?
- javascript - 批处理文件中的 WScript 是什么?
- php - PHP表单操作(POST)不发送到其他页面
- python - Pandas: how to compare several cells with a list/tuple
- android - Android:使用共享 EGL 上下文时内存泄漏