Re: [SQL] constraint with check

2010-12-13 Thread Jasen Betts
On 2010-12-13, Viktor Bojović wrote: > --0015175cd20209e2030497532e39 > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: quoted-printable > > Hi > im trying to create foreign key constraint which checks not only the > existence of key in foreign table, but it has to check if no

Re: [SQL] Constraint exclusion

2007-06-21 Thread Fernando Hevia
I see. Thanks for the tip. Regards, Fernando. -Mensaje original- De: Tom Lane [mailto:[EMAIL PROTECTED] Enviado el: Miércoles, 20 de Junio de 2007 19:37 Para: Fernando Hevia CC: 'PostgreSQL SQL List' Asunto: Re: [SQL] Constraint exclusion "Fernando Hevia" <[E

Re: [SQL] Constraint exclusion

2007-06-20 Thread Tom Lane
"Fernando Hevia" <[EMAIL PROTECTED]> writes: > -- Constraints: one partition per month > ALTER TABLE table_p01 ADD CONSTRAINT chk_table_p01_setuptime CHECK > (EXTRACT(MONTH FROM setuptime) = 1::DOUBLE PRECISION); The planner is not able to do anything with these constraints, other than if there i

Re: [SQL] Constraint on multicolumn index

2006-11-14 Thread Stuart Brooks
> > But if I want the next item following t=(a=10,b=100,c=1000): > > > select * from T > > where (a=10 AND b=100 AND c>1000) OR (a=10 AND b>100) OR (a>10) > > order by a,b,c; > > The correct way to handle this is to use a SQL-spec row comparison: > > where (a,b,c) > (10,100,1000) > > Unfortunate

Re: [SQL] Constraint on multicolumn index

2006-11-10 Thread Tom Lane
"Stuart Brooks" <[EMAIL PROTECTED]> writes: > But if I want the next item following t=(a=10,b=100,c=1000): > select * from T > where (a=10 AND b=100 AND c>1000) OR (a=10 AND b>100) OR (a>10) > order by a,b,c; The correct way to handle this is to use a SQL-spec row comparison: where (a

Re: [SQL] Constraint UNIQUE on a column not case sensitive

2006-07-01 Thread Daniel CAUNE
> -Message d'origine- > De : Michael Glaesemann [mailto:[EMAIL PROTECTED] > Envoyé : samedi 1 juillet 2006 10:01 > À : Daniel CAUNE > Cc : pgsql-sql@postgresql.org > Objet : Re: [SQL] Constraint UNIQUE on a column not case sensitive > > > On Jul 1, 200

Re: [SQL] Constraint UNIQUE on a column not case sensitive

2006-07-01 Thread Jorge Godoy
Daniel CAUNE <[EMAIL PROTECTED]> writes: > Hi, > > I would like to find an efficient solution for adding/implementing a > constraint UNIQUE on a VARCHAR column not case sensitive: > > ALTER TABLE MyTable > ADD CONSTRAINT UNQ_MyTable_MyColumn > UNIQUE (lower(MyColumn)); -- invalid synt

Re: [SQL] Constraint UNIQUE on a column not case sensitive

2006-07-01 Thread Michael Glaesemann
On Jul 1, 2006, at 22:47 , Daniel CAUNE wrote: The idea is to have an index on that column, in a not case sensitive form, i.e. lower(MyColumn). I think you're really close. Try CREATE UNIQUE INDEX ci_mycolumn_idx ON mytable(lower(mycolumn)); Does that do what you're looking for? Michael G

Re: [SQL] Constraint question

2006-05-19 Thread Markus Schaber
Hi, Andreas, Andreas Joseph Krogh wrote: >>CREATE UNIQUE INDEX foo ON onp_crm_businessfield_company(company_id) >>WHERE is_prefferred; > I also figured out that an index like this also works: > UNIQUE(company_id, is_preferred) > This works because NULL = NULL is false. But I guess your solution

Re: [SQL] Constraint question

2006-05-19 Thread Andreas Joseph Krogh
On Thursday 18 May 2006 18:38, Markus Schaber wrote: > Hi, Andreas, > > Andreas Joseph Krogh wrote: > > create table onp_crm_businessfield_company( > > businessfield_id integer not null references onp_crm_businessfield(id), > > company_id integer not null references onp_crm_relation(id), > > is_pre

Re: [SQL] Constraint question

2006-05-18 Thread Markus Schaber
Hi, Andreas, Andreas Joseph Krogh wrote: > create table onp_crm_businessfield_company( > businessfield_id integer not null references onp_crm_businessfield(id), > company_id integer not null references onp_crm_relation(id), > is_preferred boolean, > UNIQUE(businessfield_id, company_id) > ); > I

Re: [SQL] Constraint Error effect on PostgreSQL

2006-03-13 Thread Richard Huxton
Christian Paul B. Cosinas wrote: Then I have a program that insert 1(one) million times like this: Insert into unique_items(item_id) values('Item001) Ofcourse we all know that it will fail because there is already a record in the database. Would there be any bad effect on the database or none

Re: [SQL] constraint and ordered value

2005-12-29 Thread David Garamond
Daryl Richter wrote: >> No. A constraint only applies to one row at a time. If you try to >> work around >> this by calling a function that does queries it isn't guarenteed to >> work. >> And if you are thinking of calling a function that does a query, you >> aren't >> looking at saving time ove

Re: [SQL] constraint and ordered value

2005-12-29 Thread Daryl Richter
On Dec 29, 2005, at 2:16 AM, Bruno Wolff III wrote: On Wed, Dec 28, 2005 at 00:52:18 +0700, David Garamond <[EMAIL PROTECTED]> wrote: Is it possible to use only CHECK constraint (and not triggers) to completely enforce ordered value of a column (colx) in a table? By that I mean: 1. Rows

Re: [SQL] constraint and ordered value

2005-12-28 Thread Bruno Wolff III
On Wed, Dec 28, 2005 at 00:52:18 +0700, David Garamond <[EMAIL PROTECTED]> wrote: > Is it possible to use only CHECK constraint (and not triggers) to > completely enforce ordered value of a column (colx) in a table? By that > I mean: > > 1. Rows must be inserted in the order of colx=1, then colx

Re: [SQL] Constraint doesn't see a currently insertet record

2005-02-15 Thread KÖPFERL Robert
Thanks. I managed it via a trigger. > -Original Message- > From: Michael Fuhr [mailto:[EMAIL PROTECTED] > Sent: Sonntag, 13. Februar 2005 02:57 > To: KÖPFERL Robert > Cc: pgsql-sql@postgresql.org > Subject: Re: [SQL] Constraint doesn't see a currently inserte

Re: [SQL] Constraint doesn't see a currently insertet record

2005-02-12 Thread Michael Fuhr
On Fri, Feb 11, 2005 at 07:10:50PM +0100, KÖPFERL Robert wrote: > Another Idea was to make a trigger. But BTW how do I access a trigger > parameter if my trigger function must not have any parameter?? PL/pgSQL triggers can access arguments via TG_ARGV. http://www.postgresql.org/docs/8.0/

Re: [SQL] Constraint on 2 column possible?

2005-01-27 Thread Mike Rylander
On Thu, 27 Jan 2005 13:44:32 +0200, Andrei Bintintan <[EMAIL PROTECTED]> wrote: > > Hi, > > I have a table: > CREATE TABLE werke1( > id SERIAL, > id_hr int4 NOT NULL, > id_wk int4 NOT NULL > ); > > CREATE TABLE contact( > id SERIAL, > type varchar(20), > ); > > > Now id_hr and id_wk are all referen

Re: [SQL] Constraint on 2 column possible?

2005-01-27 Thread Sean Davis
On Jan 27, 2005, at 6:44 AM, Andrei Bintintan wrote: Hi,   I have a table: CREATE TABLE werke1( id SERIAL, id_hr int4 NOT NULL, id_wk int4 NOT NULL );   CREATE TABLE contact( id SERIAL, type varchar(20), ); It looks like you want a two-column primary key for table contact and then you can refere

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-13 Thread SZŰCS Gábor
Dear Rod, That sounds as good as simple ;) As for as patching, we do something like that. Developed a PHP script that compares schema files (not dumps, but source codes instead) to the actual. Say, it creates a temp table and compares it to the existing one, examining pg_attributes, pg_indexes, pg

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-13 Thread Rod Taylor
On Tue, 2004-07-13 at 13:42, SZŰCS Gábor wrote: > Dear Rod, > > Thanks. It'll be a pain to have two versions between the prod and devel > servers, but I'll forward this info to the chief. You can make this part easier on yourself. Dump the structure from production and migrate it to devel (fix t

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-13 Thread SZŰCS Gábor
Dear Rod, Thanks. It'll be a pain to have two versions between the prod and devel servers, but I'll forward this info to the chief. Thanks again, G. %--- cut here ---% \end - Original Message - From: "Rod Taylor" <[EMAIL PROTECTED]> Sent: Tuesday,

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-13 Thread Rod Taylor
> Checked, and So do you say, this problem persists in dbs dumped from 7.4 to > 7.4 too? i.e. upgrading to 7.4 (which we tested for quite some time now) > won't help? There may have been some minor fiddling to make it easier, but I wouldn't call it fixed by any means. > trying dump confirmed thi

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-13 Thread SZŰCS Gábor
ything. G. %--- cut here ---% \end - Original Message - From: "Rod Taylor" <[EMAIL PROTECTED]> Sent: Monday, July 12, 2004 2:51 PM Subject: Re: [SQL] Constraint->function dependency and dump in 7.3 > On Mon, 2004-07-12 at 08:29, SZ

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-12 Thread Együd Csaba
Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of SZŰCS Gábor > Sent: 2004. július 12. 14:30 > To: [EMAIL PROTECTED] > Subject: Re: [SQL] Constraint->function dependency and dump in 7.3 > > > Dear Fellow Countymen, > > I fear none of your

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-12 Thread Rod Taylor
On Mon, 2004-07-12 at 08:29, SZŰCS Gábor wrote: > Dear Fellow Countymen, > > I fear none of your answers are acceptable for me. Also, from Csaba's > answer, this sounds to me more like a bug in pg_dump v7.3. It is a bug (or a missing feature) that should be solved with v7.5 for restoring to 7.5 o

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-12 Thread SZŰCS Gábor
Dear Fellow Countymen, I fear none of your answers are acceptable for me. Also, from Csaba's answer, this sounds to me more like a bug in pg_dump v7.3. (1) I wish to transfer the full dump for daily mirroring. Thus, data-only isn't an option. (2) Dumping functions first won't work for SQL functi

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-09 Thread Verebes Gabor
L PROTECTED] Subject: Re: [SQL] Constraint->function dependency and dump in 7.3 Hi Gábor! I had the same problem and someone pointed me the right direction. I tried to define a table default clause refering a function. Reloading the dump file an error messaged raised up saying that the referred

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-08 Thread Együd Csaba
Hi Gábor! I had the same problem and someone pointed me the right direction. I tried to define a table default clause refering a function. Reloading the dump file an error messaged raised up saying that the referred function doesn't exist. This is because dumping out the schema pg_dump pushes out

Re: [SQL] Constraint problems

2002-09-27 Thread GB Clark
On Fri, 27 Sep 2002 11:29:34 -0700 (PDT) Stephan Szabo <[EMAIL PROTECTED]> wrote: > On Fri, 27 Sep 2002, GB Clark wrote: > > > CREATE TABLE sysusers ( > > user_id INTEGER DEFAULT nextval('sysusers_user_id_seq') > > UNIQUE NOT NULL PRIMARY K

Re: [SQL] Constraint problems

2002-09-27 Thread Stephan Szabo
On Fri, 27 Sep 2002, GB Clark wrote: > CREATE TABLE sysusers ( > user_id INTEGER DEFAULT nextval('sysusers_user_id_seq') > UNIQUE NOT NULL PRIMARY KEY, > username text NOT NULL UNIQUE, > password

Re: [SQL] constraint

2002-07-03 Thread Christopher Kings-Lynne
Hi Ricardo, I assume you're talking about foreign key constraints? Dropping a constraint is a real pain in all versions of Postgres up to and including 7.2.1. You will need to manually drop the RI trigger on the child table and the two triggers on the parent table. Techdocs has some informatio

Re: [SQL] constraint/restrict

2001-02-14 Thread Jie Liang
add an foriegn key on address(country_id), let country(id) be a primary key. Jie LIANG St. Bernard Software Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 [EMAIL PROTECTED] www.stbernard.com www.ipinc.com On Wed, 14 Feb 2001, Olaf Marc Za

Re: [SQL] constraint/restrict

2001-02-14 Thread Richard Huxton
From: "Olaf Marc Zanger" <[EMAIL PROTECTED]> > hi there, > > with two tables i want to make some constraint-restrictions > > to make sure that now country-row is deleted if there is still a country_id > in address table. > > e.g. > > address: 1, 2, ... > country: 2, ... > > now country wouldn't b

Re: [SQL] constraint

2000-05-29 Thread Jan Wieck
Bernie Huang wrote: > Hi, > > I am a newbie to SQL. Could someone please explain why do I need a > contraint, and how do I use it in SQL? An example is needed. Thanks Constraints are used to have the database engine ensure the integrity of the data. It'l like teaching the database it