【发布时间】:2016-10-15 19:58:48
【问题描述】:
我有一个巨大的 OSM 数据集,其中包含很多我想摆脱的纯空列。
DO
$do$
DECLARE
_column TEXT;
BEGIN
FOR _column IN
SELECT attname
FROM pg_stats where tablename = 'rail_l'
and most_common_vals is null
and most_common_freqs is null
and histogram_bounds is null
and correlation is null
and null_frac = 1
LOOP
RAISE NOTICE '%', _column;
EXECUTE
'ALTER TABLE rail_l DROP COLUMN ' || _column;
END LOOP;
END
$do$
包含冒号的列名会导致以下错误:
错误:“:”处或附近的语法错误
第 1 行:ALTER TABLE rail_l DROP COLUMN 生成器:来源
查询:ALTER TABLE rail_l DROP COLUMN 生成器:来源
CONTEXT:PL/pgSQL 函数 inline_code_block 第 16 行在 EXECUTE 语句
SQL 状态:42601
也许是一个初学者的问题,因为到目前为止我只将 postgresql 用于简单查询,但谢天谢地,我会接受任何建议。
【问题讨论】:
标签: postgresql parsing iterator openstreetmap isnull