dbTalk Databases Forums  

COPY data and referential triggers ...

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss COPY data and referential triggers ... in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
James Robinson
 
Posts: n/a

Default COPY data and referential triggers ... - 10-23-2004 , 05:51 PM






Just a sanity check -- data fed into pg using the

COPY tablename (col1, col2) FROM stdin;
... data
\.

Does not cause referential triggers to fire (i.e. foreign keys), right?
It seems to operate this way, yet I didn't see this mentioned
explicitly in the SQL reference manual page on the COPY command.

----
James Robinson
Socialserve.com


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: COPY data and referential triggers ... - 10-23-2004 , 06:55 PM






James Robinson <jlrobins (AT) socialserve (DOT) com> writes:
Quote:
Just a sanity check -- data fed into pg using the
COPY tablename (col1, col2) FROM stdin;
... data
\.

Does not cause referential triggers to fire (i.e. foreign keys), right?
Sure it does.

regression=# create table t1 (f1 int primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t1_pkey" for table "t1"
CREATE TABLE
regression=# create table t2 (f1 int references t1, f2 int);
CREATE TABLE
regression=# copy t2(f1,f2) from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
Quote:
3 4
\.
ERROR: insert or update on table "t2" violates foreign key constraint "$1"
DETAIL: Key (f1)=(3) is not present in table "t1".

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.