Re: [SQL] unique constraint on views

2008-12-10 Thread Jyoti Seth
I want to put unique constraint on columns of more than one table. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of A. Kretschmer Sent: Wednesday, December 10, 2008 6:04 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] unique constraint on views In

Re: [SQL] unique constraint on views

2008-12-10 Thread A. Kretschmer
In response to Jyoti Seth : > Hi All, > > Is it possible to add unique constraint on updateable views in postgres? Add the constraint to the base-table. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA

Re: [SQL] unique constraint instead of primary key? what

2006-02-10 Thread Chris Browne
gry@ll.mit.edu (george young) writes: > On 9 Feb 2006 08:22:59 -0800 > "BigSmoke" <[EMAIL PROTECTED]> threw this fish to the penguins: > >> If my tables have one or more UNIQUE constraints/indices, I still add a >> "id SERIAL PRIMARY KEY" field to most of my tables. This makes >> referencing easier

Re: [SQL] unique constraint instead of primary key? what

2006-02-09 Thread BigSmoke
I mean that you can't easily base a foreign key constraint on a field that is not NOT NULL UNIQUE. - Rowan ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PRO

Re: [SQL] unique constraint instead of primary key? what

2006-02-09 Thread george young
On 9 Feb 2006 08:22:59 -0800 "BigSmoke" <[EMAIL PROTECTED]> threw this fish to the penguins: > If my tables have one or more UNIQUE constraints/indices, I still add a > "id SERIAL PRIMARY KEY" field to most of my tables. This makes > referencing easier and faster. It also improves consistency, whi

Re: [SQL] unique constraint instead of primary key? what disadvantage(ODBC usage)?

2006-02-09 Thread Tom Lane
"BigSmoke" <[EMAIL PROTECTED]> writes: > As far as I know, though, PRIMARY KEY does the same thing as UNIQUE NOT > NULL in PostgreSQL. They are 99.9% the same --- the *only* difference AFAIR is that PRIMARY KEY establishes a default column-to-reference for FOREIGN KEY references to the table. UNI

Re: [SQL] unique constraint instead of primary key? what disadvantage(ODBC usage)?

2006-02-09 Thread BigSmoke
If my tables have one or more UNIQUE constraints/indices, I still add a "id SERIAL PRIMARY KEY" field to most of my tables. This makes referencing easier and faster. It also improves consistency, which is never a bad thing in my opinion. As far as I know, though, PRIMARY KEY does the same thing as

Re: [SQL] unique constraint instead of primary key? what

2006-02-09 Thread Richard Huxton
george young wrote: On Wed, 08 Feb 2006 18:34:22 -0800 Ken Hill <[EMAIL PROTECTED]> threw this fish to the penguins: On Wed, 2006-02-08 at 21:04 -0500, george young wrote: So the 'steps' table is logically indexed by (run, opset_num, step_num). But some opsets are not in runs, and some steps

Re: [SQL] unique constraint instead of primary key? what

2006-02-08 Thread george young
On Wed, 08 Feb 2006 18:34:22 -0800 Ken Hill <[EMAIL PROTECTED]> threw this fish to the penguins: > On Wed, 2006-02-08 at 21:04 -0500, george young wrote: > > > [PostgreSQL 8.1.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.0.1] > > I'm designing a completely new schema for my database. A ma

Re: [SQL] unique constraint instead of primary key? what

2006-02-08 Thread Ken Hill
On Wed, 2006-02-08 at 21:04 -0500, george young wrote: [PostgreSQL 8.1.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.0.1] I'm designing a completely new schema for my database. A major criterion is that it facilitate ad-hoc queries via MS-access, excel and OpenOffice, presumably with O

Re: [SQL] UNIQUE constraint

2004-08-15 Thread Sascha Ziemann
Michael Glaesemann <[EMAIL PROTECTED]> writes: > On Aug 7, 2004, at 3:25 AM, Sascha Ziemann wrote: > > CREATE TABLE example ( > > a integer, > > b integer, > > c integer, > > UNIQUE (a, c) > > ); > > > > But it is not clean to me. Does the above example mean that the list > > of p

Re: [SQL] UNIQUE constraint

2004-08-08 Thread Michael Glaesemann
On Aug 7, 2004, at 3:25 AM, Sascha Ziemann wrote: CREATE TABLE example ( a integer, b integer, c integer, UNIQUE (a, c) ); But it is not clean to me. Does the above example mean that the list of pairs must be unique Yes. Does the following table fullfill the UNIQUE clause of the ex

Re: [SQL] Unique Constraint with foreign Key

2004-05-17 Thread Karsten Hilbert
> > or Can i have varchar types of size 50 as primary keys in Postgres. > Yes. But unless the 50 character limit comes from a business rule, you > might want to use the type 'text'. And if that limit does come from a business rule you might want to think twice whether using columns constrained by

Re: [SQL] Unique Constraint with foreign Key

2004-05-17 Thread Bruno Wolff III
On Tue, Feb 10, 2004 at 12:03:36 -0500, [EMAIL PROTECTED] wrote: > Hi all i am using postgres and torque > I have a column x in Table A of type varchar and NOT NULL. I want to > impose a unique key constraint on that table and column y is the primary > key. > I have another Table B with column x.

Re: [SQL] Unique Constraint with foreign Key

2004-02-17 Thread Greg Patnude
essage- From: Jan Wieck [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 17, 2004 6:42 AM To: Greg Patnude Cc: [EMAIL PROTECTED] Subject: Re: [SQL] Unique Constraint with foreign Key Greg Patnude wrote: > Pleas also note that the referenced column in the foreign table either needs > to be th

Re: [SQL] Unique Constraint with foreign Key

2004-02-17 Thread Jan Wieck
Greg Patnude wrote: Pleas also note that the referenced column in the foreign table either needs to be the PRIMARY KEY or have a unique constraint on it or maybe it just requires an index on it -- I'm not sure but I discovered that if the column in the foreign table (containing the REFERENCED key..

Re: [SQL] Unique Constraint with foreign Key

2004-02-15 Thread Greg Patnude
Pleas also note that the referenced column in the foreign table either needs to be the PRIMARY KEY or have a unique constraint on it or maybe it just requires an index on it -- I'm not sure but I discovered that if the column in the foreign table (containing the REFERENCED key...) is NOT the primar

Re: [SQL] Unique Constraint Based on Date Range

2003-09-22 Thread Manfred Koizar
On Sat, 20 Sep 2003 18:55:34 -0400, Kevin Houle <[EMAIL PROTECTED]> wrote: > SELECT INTO result * FROM table_rates WHERE > effective_date >= NEW.effective_date AND > expiry_date <= NEW.expiry_date AND > cost = NEW.cost; > IF FOUND THEN >RAISE EXCEPTION ''record ove

Re: [SQL] Unique Constraint Based on Date Range

2003-09-21 Thread Kevin Houle
Andrew Milne wrote: ... create table rates ( effective_date AS timestamp, expiry_date AS timestamp, cost AS numeric (12,2), access_time AS integer (in minutes) ); So for a given cost, there may not be a record where the effective date of one record overlaps the expiry date of anothe

Re: [SQL] Unique constraint over null values

2002-09-30 Thread Josh Berkus
Thrasher, > I think I'll follow your advice, as this is the method that I had in my > pocket to use if I had no response. I tried with TRIM and other > functions in the CHECK constraint, but I guess that I cannot use > functions over a check field. > > It surprised me, but anyway, I'll do th

Re: [SQL] Unique constraint over null values

2002-09-30 Thread Thrasher
Hi Josh, I think I'll follow your advice, as this is the method that I had in my pocket to use if I had no response. I tried with TRIM and other functions in the CHECK constraint, but I guess that I cannot use functions over a check field. It surprised me, but anyway, I'll do that. Thanks a

Re: [SQL] Unique constraint over null values

2002-09-30 Thread Josh Berkus
Thrasher, > where type can be 's' for 'single' and 'x' for extended, so s should > mean that there is only the type and data1 field, and x means that all > fields are set. > > How can I set a unique constraint like CHECK (type = 's' AND UNIQUE > (type, data1)) OR (type = 'x' AND UNIQUE (type