From: Tom Good <tomg@nrnet.org>
To: Richard Lynch <lynch@lscorp.com>
Cc: Colin Dick <cdick@mail.ocis.net>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Creating table with unique key.
Date: Thu, 6 Aug 1998 08:16:44 -0400 (EDT)
Message-ID: <Pine.LNX.3.95.980806080723.2040A-100000@mailhost.nrnet.org> (raw)
In-Reply-To: <v02140b58b1ee55140c5b@[207.152.64.133]>
On Wed, 5 Aug 1998, Richard Lynch wrote:
> www.postgresql.org/docs/man/create_table.1.html does not seem to allow for
> any spiffy keywords like UNIQUE nor PRIMARY KEY... at least not if I'm
> understanding it properly.
>
> Disclaimer: I think the docs are wrong, not that at least one of them
> won't work.
Rich & Colin,
Have a look below at how I convince pg to make a p_key with a check
constraint...I got this from the man page and (even better methinks)
from \h <cmd> at the isql prompt.
/***********************************************************************
#!/usr/bin/perl -w
use DBI;
use strict;
my $dbh = DBI->connect("dbi:Pg:dbname=registry", "", "", { RaiseError => 1 });
my $rv =
$dbh->do( "
CREATE TABLE central
(client_lname char (15) not null, client_fname char (15) not null,
client_id int not null primary key check (client_id > 100000),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
a_lias char (25), home_stat char (30), home_less int,
address_1 char (40), zip_code char (10), client_dob date,
gen_der char (1), eth_nic char (8), marital_stat char (10),
diagnosis_1 char (40), diagnosis_2 char (40), dsm_1 char (6),
dsm_2 char (6), drug_use char (1), alcohol char (1),
gambler char (1), in_out char (1), t_date date,
place_ment char (25), sent_to char (25), input_by char (40));
" );
$dbh->disconnect;
exit;
***********************************************************************/
Cheers,
Tom
----------- Sisters of Charity Medical Center ----------
Department of Psychiatry
----
Thomas Good, System Administrator <tomg@q8.nrnet.org>
North Richmond CMHC/Residential Services Phone: 718-354-5528
75 Vanderbilt Ave, Quarters 8 Fax: 718-354-5056
Staten Island, NY 10304 www.panix.com/~ugd
----
Powered by PostgreSQL 6.3.2 / Perl 5.004 / DBI-0.91::DBD-PG-0.69
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tomg@nrnet.org, lynch@lscorp.com, cdick@mail.ocis.net
Subject: Re: [SQL] Creating table with unique key.
In-Reply-To: <Pine.LNX.3.95.980806080723.2040A-100000@mailhost.nrnet.org>
References: <v02140b58b1ee55140c5b@[207.152.64.133]> <Pine.LNX.3.95.980806080723.2040A-100000@mailhost.nrnet.org>
* 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