Re: [SQL] Composite primary keys

2009-06-24 Thread Harald Fuchs
In article <24680.1245784...@sss.pgh.pa.us>, Tom Lane writes: > Joshua Tolley writes: >> Primary keys are NOT NULL and UNIQUE. You can't have null values in a primary >> key. > On reflection I think the OP's beef is that we complain about this: > regression=# create table t (f1 int null not nu

Re: [SQL] Composite primary keys

2009-06-23 Thread Tom Lane
Joshua Tolley writes: > Primary keys are NOT NULL and UNIQUE. You can't have null values in a primary > key. On reflection I think the OP's beef is that we complain about this: regression=# create table t (f1 int null not null); ERROR: conflicting NULL/NOT NULL declarations for column "f1" of t

Re: [SQL] Composite primary keys

2009-06-23 Thread Joshua Tolley
On Tue, Jun 23, 2009 at 05:14:36PM +0200, Harald Fuchs wrote: > test=# CREATE TABLE t2 ( > test(# id int NOT NULL REFERENCES t1, > test(# language char(3) NULL, > test(# txt text NOT NULL, > test(# PRIMARY KEY (id, language) > test(# ); > CREATE TABLE > test=# INSERT INTO

Re: [SQL] Composite primary keys

2009-06-23 Thread Oliveiros Cristina
error informing that primary key constraint is being violated. But IMHO the first INSERT is legal SQL Best, Oliveiros - Original Message - From: "Harald Fuchs" To: Sent: Tuesday, June 23, 2009 4:14 PM Subject: [SQL] Composite primary keys I tried to throw some invalid S

Re: [SQL] Composite primary keys

2009-06-23 Thread Tom Lane
Harald Fuchs writes: > I tried to throw some invalid SQL to PostgreSQL and found its reaction > confusing: > test(# language char(3) NULL, This is documented as being a no-op specification. regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.

[SQL] Composite primary keys

2009-06-23 Thread Harald Fuchs
I tried to throw some invalid SQL to PostgreSQL and found its reaction confusing: $ psql test psql (8.4beta2) Type "help" for help. test=# CREATE TABLE t1 ( test(# id serial NOT NULL, test(# name text NOT NULL, test(# PRIMARY KEY (id) test(# ); CREATE TABLE te