当我尝试执行以下操作时出现以下错误:
pgloader --with "quote identifiers" "mysql://..." "postgresql://..."
我收到此错误:
What I am doing here?
Database error 42703: column ""invoiceNo"" of relation "Order" does not exist
CONTEXT: PL/pgSQL function inline_code_block line 6 at FOR over SELECT rows
QUERY:
DO $$
DECLARE
n integer := 0;
r record;
BEGIN
FOR r in
SELECT 'select '
|| trim(trailing ')'
from replace(pg_get_expr(d.adbin, d.adrelid),
'nextval', 'setval'))
|| ', (select greatest(max(' || quote_ident(a.attname) || '), (select seqmin from pg_sequence where seqrelid = ('''
|| pg_get_serial_sequence(quote_ident(nspname) || '.' || quote_ident(relname), quote_ident(a.attname)) || ''')::regclass limit 1), 1) from only '
|| quote_ident(nspname) || '.' || quote_ident(relname) || '));' as sql
FROM pg_class c
JOIN pg_namespace n on n.oid = c.relnamespace
JOIN pg_attribute a on a.attrelid = c.oid
JOIN pg_attrdef d on d.adrelid = a.attrelid
and d.adnum = a.attnum
and a.atthasdef
WHERE relkind = 'r' and a.attnum > 0
and pg_get_expr(d.adbin, d.adrelid) ~ '^nextval'
and c.oid in (select oid from reloids)
LOOP
n := n + 1;
EXECUTE r.sql;
END LOOP;
PERFORM pg_notify('seqs', n::text);
END;
$$;
它是否必须与这里的双引号做一些事情:
column ""invoiceNo"" of
?我不知道如何解决这个问题。当我在没有 --with "quote identifiers"
的情况下执行相同的命令时,错误消失了 - 但我的表格不是驼峰式大小写,这不是我想要的。
您找到解决方案了吗?我有完全相同的问题。