Received: from mail1.panix.com (mail1.panix.com [166.84.0.212]) by hub.org (8.8.8/8.7.5) with ESMTP id IAA14691 for ; Thu, 6 Aug 1998 08:53:26 -0400 (EDT) Received: from mailhost.nrnet.org (root@mailhost.nrnet.org [166.84.192.39]) by mail1.panix.com (8.8.8/8.8.8/PanixM1.3) with ESMTP id IAA17412; Thu, 6 Aug 1998 08:53:23 -0400 (EDT) Received: from localhost (tomg@localhost) by mailhost.nrnet.org (8.8.4/8.8.4) with SMTP id IAA02096; Thu, 6 Aug 1998 08:16:44 -0400 Date: Thu, 6 Aug 1998 08:16:44 -0400 (EDT) From: Tom Good To: Richard Lynch cc: Colin Dick , pgsql-sql@postgreSQL.org Subject: Re: [SQL] Creating table with unique key. In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 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 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