[SQL] request for help with COPY syntax

2007-10-23 Thread Chuck D.
Greetings everyone, I'm having some trouble with COPY syntax. I'm importing the cities data from MaxMind, but I run into errors when the data adds a double quote inside a field. The data is CSV, comma delimited, no quotes around fields, ISO-8859-1. I'm using COPY with the defaults and setting

Re: [SQL] request for help with COPY syntax

2007-10-23 Thread Andrew Sullivan
On Tue, Oct 23, 2007 at 10:19:07AM -0600, Chuck D. wrote: > by,kruhavyetskalini"na,KruhavyetsKalini"na,02,52.1438889,31.6925 > > There are a couple " where I would expect to see ' instead. I see other > lines > in the data that use both in a field. Ugh. I think I would normalise the data befo

Re: [SQL] request for help with COPY syntax

2007-10-23 Thread Fernando Hevia
> -Mensaje original- > De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > En nombre de Chuck D. > > Anyone known how I can rewrite the COPY command to allow those " or ' > within > the data? After a couple days I wasn't able to find any examples to help. > Hi Chuck, Do you need those c

[SQL] Quick question re foreign keys.

2007-10-23 Thread Paul Lambert
I have a table where one column references by foreign key a column from another table. However, the column in this first table does not always contain data which results in a not-null constraint violation when I attempt an insert. My question therefore is, is it possible to create a foreign ke

Re: [SQL] Quick question re foreign keys.

2007-10-23 Thread Phillip Smith
> My question therefore is, is it possible to create a foreign key that is > conditional, i.e. only enforce the foreign key where the value in that > table is not null. My understanding from reading previous threads on this topic is the answer is no, however you could make your own pseudo-foreign

Re: [SQL] Quick question re foreign keys.

2007-10-23 Thread Tom Lane
Paul Lambert <[EMAIL PROTECTED]> writes: > I have a table where one column references by foreign key a column from > another table. However, the column in this first table does not always > contain data which results in a not-null constraint violation when I > attempt an insert. > My question t

Re: [SQL] request for help with COPY syntax

2007-10-23 Thread Adrian Klaver
On Tuesday 23 October 2007 9:19 am, Chuck D. wrote: > Greetings everyone, > > I'm having some trouble with COPY syntax. > > I'm importing the cities data from MaxMind, but I run into errors when the > data adds a double quote inside a field. > > The data is CSV, comma delimited, no quotes around fi

Re: [SQL] Quick question re foreign keys.

2007-10-23 Thread Paul Lambert
Tom Lane wrote: If I'm understanding you correctly, the problem is not the foreign key, it's that you marked the column NOT NULL. A foreign key constraint by itself will allow a NULL in the referencing column to pass. You choose whether you want to allow that or not by separately applying a NO

Re: [SQL] Quick question re foreign keys.

2007-10-23 Thread D'Arcy J.M. Cain
On Wed, 24 Oct 2007 11:00:47 +0800 Paul Lambert <[EMAIL PROTECTED]> wrote: > It's marked not null as a result of being part of the primary key for > that table which I can't really get around. > > I can get away with not having the foreign key though, so I'll have to > go down that path. It can