这不起作用
DO $$
<<first_block>>
DECLARE
rec RECORD;
BEGIN
FOR rec IN SELECT datname
FROM pg_database
WHERE datistemplate = false
AND datname NOT IN ('postgres')
LOOP
DROP DATABASE rec.datname;
END LOOP;
END first_block
$$;
但这可行
DO $$
<<first_block>>
DECLARE rec RECORD;
BEGIN
FOR rec IN SELECT datname
FROM pg_database
WHERE datistemplate = false
AND datname NOT IN ('postgres')
LOOP
RAISE NOTICE '%', rec.datname;
END LOOP;
END first_block
$$;
我的第一个查询出了什么问题?我正在尝试删除所有数据库