COPY with default values?

Поиск
Список
Период
Сортировка
От Jeff Boes
Тема COPY with default values?
Дата
Msg-id 20010525100637.4d410e3c.jboes@nexcerpt.com
обсуждение исходный текст
Ответы Re: COPY with default values?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Let's say I have a table of keywords, with a SERIAL primary key.

CREATE TABLE keywords (
  key_id  SERIAL PRIMARY KEY,
  key_text TEXT
);

Now I would like to initialize this table with a COPY statement, but
without supplying values for the primary key. In other words, how can I
use COPY to perform the same function as

INSERT INTO keywords (keyword_text) VALUES ('foo');
INSERT INTO keywords (keyword_text) VALUES ('bar');
...

I have tried

COPY keywords FROM stdin USING DELIMITERS '|';
|foo
|bar
...

and also

0|foo
0|bar

and even

\N|foo
\N|bar

I even tried creating a view on keywords that has only keyword_text, and
copying into THAT--no luck. Then I wrote a rule to replace inserts on the
view with inserts on the table, but apparently COPY doesn't trigger INSERT
rules. Grumble...


--
Jeff Boes                                             vox 616.226.9550
Database Engineer                                     fax 616.349.9076
Nexcerpt, Inc.                                      jboes@nexcerpt.com


В списке pgsql-general по дате отправления:

Предыдущее
От: Jeff Boes
Дата:
Сообщение: pl-perl setup?
Следующее
От: "Len Morgan"
Дата:
Сообщение: Re: COPY with default values?