【问题标题】:Postgres Insert statements from stdinPostgres 从标准输入插入语句
【发布时间】:2019-12-29 06:47:32
【问题描述】:

我有一个转储文件是:

COPY public.applications (id, reference_id, lead_id) FROM stdin;

后面是需要添加的行。

我想从标准输入插入这些行而不是复制,因为复制正在替换我的整个表(删除表中的现有数据)。我只想添加行,而不是删除任何现有行。

我试过了:

insert into public.applications (id, reference_id, lead_id) values FROM stdin;

但这是不正确的语法。这样做的正确方法是什么? 有没有办法调整复制命令只添加行而不替换表?

【问题讨论】:

  • copy 不会删除现有行

标签: sql-insert postgresql-9.5


【解决方案1】:

正如目前在 cmets 中所指出的,copy 不进行替换。 也就是说,COPY public.applications (id, reference_id, lead_id) FROM stdin; 将模拟与插入相同的行为。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2014-10-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-26
  • 1970-01-01
  • 2015-03-02
  • 2011-07-07
相关资源
最近更新 更多