From: Richard Huxton <dev@archonet.com>
To: Charles Hauser <chauser@duke.edu>
To: PSQL_list <pgsql-sql@postgresql.org>
Subject: Re: Adding foreign key constraint post table creation
Date: Wed, 11 Dec 2002 09:58:07 +0000
Message-ID: <200212110958.07110.dev@archonet.com> (raw)
In-Reply-To: <1039450281.32471.44.camel@pandorina.biology.duke.edu>
References: <1039450281.32471.44.camel@pandorina.biology.duke.edu>
On Monday 09 Dec 2002 4:11 pm, Charles Hauser wrote:
> All,
>
> A couple of novice questions:
>
>
> I would like to modify an existing TABLE by addinga new column (FOREIGN
> KEY):
>
> type_id int not null,
> foreign key (type_id) references cvterm (cvterm_id),
>
>
> Will this work ( running PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled
> by GCC 2.96):
You'll need to check your manuals for 7.1.3 - look in the SQL command
reference under ALTER TABLE. It should work with current versions but I don't
have v7.1.3 to hand.
> I would like to load data into the table below from a file lacking the
> timestamp fields, where the file structure is:
>
> COPY table FROM STDIN;
> 1 feature_type types of features \N
> 2 3'-exon \N 1
>
> This fails as the timestamp fields are 'not null'. Othere than
> generating INSERT stmts for the data how else could I enter the data?
You could process the file with perl/awk etc. and add the required timestamps.
I don't think COPY substitutes default values for you.
--
Richard Huxton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, chauser@duke.edu
Subject: Re: Adding foreign key constraint post table creation
In-Reply-To: <200212110958.07110.dev@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox