【发布时间】:2021-03-09 17:47:28
【问题描述】:
我正在尝试在我的 postgres 数据库上创建新模式,其名称存储在现有表中, 我的查询如下所示:
DO $$
declare s_name text;
BEGIN
IF NOT EXISTS(
SELECT schema_name
FROM information_schema.schemata
THEN
SELECT name INTO s_name FROM table_name;
execute 'create schema '|| quote_ident(s_name);
Raise notice 'status:%', schema created successfully;
END IF;
END
$$;
【问题讨论】:
-
你的问题到底是什么?
-
现有表中存储了多个值,因此需要动态创建多个模式并且不应该存在,尝试循环它但卡在中间
标签: postgresql