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