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

[SQL] unique constraint on views

2008-12-10 Thread Jyoti Seth
Hi All, Is it possible to add unique constraint on updateable views in postgres? Thanks, Jyoti Seth -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

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

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

2006-02-08 Thread george young
[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 ODBC. My question regards the use of UNIQUE constraints inste

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

[SQL] UNIQUE constraint

2004-08-08 Thread Sascha Ziemann
Hi, I have a question about the UNIQUE constraint. The documentation describes this example: 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 or is it only a sho

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

[SQL] Unique Constraint with foreign Key

2004-02-10 Thread mohan
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. can i make this column x as a foreign key on column x in table A. or Can i h

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

[SQL] Unique Constraint Based on Date Range

2003-09-20 Thread Andrew Milne
I'm looking to apply a unique constraint to a table such that field A must be unique based on the date range from Field B to Field C. This is for a rate based service model whereby, for example, $5 is worth 1 hour of Internet access. But next week, because of increased competition, $5 is wort

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

[SQL] Unique constraint over null values

2002-09-30 Thread Thrasher
Hi all, I have a table like CREATE TABLE a ( typeCHAR (1) NOT NULL, data1 CHAR (16) NOT NULL, data2 CHAR (16) NULL ); 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 fie

Re: [ADMIN] [SQL] Urgent - SQL Unique constraint error (long)

2002-08-19 Thread Darrin Domoney
PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [ADMIN] [SQL] Urgent - SQL Unique constraint error (long) On Mon, 19 Aug 2002, Darrin Domoney wrote: > Thanks for the response but the answer is no. Owing to the > ongoing issue with inherited tables in 7.x I have opted

Re: [SQL] Urgent - SQL Unique constraint error (long)

2002-08-19 Thread Stephan Szabo
On Mon, 19 Aug 2002, Darrin Domoney wrote: > Thanks for the response but the answer is no. Owing to the > ongoing issue with inherited tables in 7.x I have opted to create three > tables: > Contains generic traits regardless of "class or role". > Person -> PK person_id > > Staff as certain

Re: [SQL] [NOVICE] Urgent - SQL Unique constraint error (long)

2002-08-19 Thread Darrin Domoney
lf Of paul butler Sent: August 19, 2002 1:11 PM To: [EMAIL PROTECTED] Subject: Re: [NOVICE] Urgent - SQL Unique constraint error (long) From: "Darrin Domoney" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>

Re: [SQL] Urgent - SQL Unique constraint error (long)

2002-08-19 Thread Darrin Domoney
---Original Message- From: Stephan Szabo [mailto:[EMAIL PROTECTED]] Sent: August 19, 2002 12:41 PM To: Darrin Domoney Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [SQL] Urgent - SQL Unique constraint error (long) On Mon, 19 Aug 2002, Darrin Domoney wrote: > An admitte

Re: [SQL] Urgent - SQL Unique constraint error (long)

2002-08-19 Thread Stephan Szabo
On Mon, 19 Aug 2002, Darrin Domoney wrote: > An admitted newbie to postgresql I am trying to commit a new design > my development server using pgAdminII. > > Everything appears to work OK but I am having real grief with my > SQL generating errors - most of which I have cleared myself but > one th

[SQL] Urgent - SQL Unique constraint error (long)

2002-08-19 Thread Darrin Domoney
An admitted newbie to postgresql I am trying to commit a new design my development server using pgAdminII. Everything appears to work OK but I am having real grief with my SQL generating errors - most of which I have cleared myself but one that I am unsure how to handle: UNIQUE constraint for