Re: [SQL] FOREIGN KEY and AccessExclusiveLock

2004-09-28 Thread Achilleus Mantzios
O Tom Lane έγραψε στις Sep 28, 2004 : > Achilleus Mantzios <[EMAIL PROTECTED]> writes: > > Whats the purpose of the AccessExclusiveLock on parent table? > > We're adding a trigger to it. >From the docs: Acquired by the ALTER TABLE, DROP TABLE, REINDEX, CLUSTER, and VACUUM FULL commands. This is

Re: [SQL] CHECK col A not NULL if col B='x'

2004-09-28 Thread Tom Lane
T E Schmitz <[EMAIL PROTECTED]> writes: > I noticed a table constraint can be added via ALTER TABLE. Is it correct > that a column constraint cannot be added via the ALTER TABLE other than > by dropping and adding the column? (I am using psql 7.4.2.) There is no difference between table and colu

Re: [SQL] Doubt

2004-09-28 Thread Paul Thomas
On 22/09/2004 12:11 S.Sreejith wrote: Sir, I am new to PostgreSQL. I have a doubt. Now i am doing one project in .NET technology with postgres(linux) as database. I am using pgADMIN and pgManager as tools for database releted activities. Now i am able to create functions with 'sql' language.

Re: [SQL] CHECK col A not NULL if col B='x'

2004-09-28 Thread T E Schmitz
Hello again, Martin Marques wrote: El Mar 28 Sep 2004 11:02, T E Schmitz escribió: Is it possible to set up a table CHECK, which ensures that column A is NOT NULL if column B = 'x' ? CONSTRAINT somename CHECK (B <> 'x' OR A IS NOT NULL) I noticed a table constraint can be added via ALTER TABLE. Is

Re: [SQL] CHECK col A not NULL if col B='x'

2004-09-28 Thread T E Schmitz
Hola Martin! Martin Marques wrote: El Mar 28 Sep 2004 11:02, T E Schmitz escribió: Is it possible to set up a table CHECK, which ensures that column A is NOT NULL if column B = 'x' ? CONSTRAINT somename CHECK (B <> 'x' OR A IS NOT NULL) This is brilliant. Only detected this today. Don't know how I

Re: [SQL] Best way to know if there is a row

2004-09-28 Thread Tom Lane
Martin Marques <[EMAIL PROTECTED]> writes: > I need to know if there is at least one row in the relation that comes from a > determinated query. Which is the best way to do this: > (a) Build the query with "SELECT * ..." and after executing the query see if > numRows()>0 > (b) Build the query wi

Re: [SQL] FOREIGN KEY and AccessExclusiveLock

2004-09-28 Thread Achilleus Mantzios
O Tom Lane έγραψε στις Sep 28, 2004 : > Achilleus Mantzios <[EMAIL PROTECTED]> writes: > > Whats the purpose of the AccessExclusiveLock on parent table? > > We're adding a trigger to it. >From the docs: Acquired by the ALTER TABLE, DROP TABLE, REINDEX, CLUSTER, and VACUUM FULL commands. This i

Re: [SQL] CHECK col A not NULL if col B='x'

2004-09-28 Thread Alexander M. Pravking
On Tue, Sep 28, 2004 at 03:02:02PM +0100, T E Schmitz wrote: > Hello, > > Is it possible to set up a table CHECK, which ensures that column A is > NOT NULL if column B = 'x' ? Sure. [EMAIL PROTECTED] CREATE TABLE test ( [EMAIL PROTECTED](# a integer check (case when b = 'x' then a is not null e

Re: [SQL] CHECK col A not NULL if col B='x'

2004-09-28 Thread Martin Marques
El Mar 28 Sep 2004 11:02, T E Schmitz escribió: > Hello, > > Is it possible to set up a table CHECK, which ensures that column A is > NOT NULL if column B = 'x' ? CONSTRAINT constraint_name ] CHECK (expression) CHECK (expression) The CHECK clause specifies an expression producing a Boolean r

Re: [SQL] FOREIGN KEY and AccessExclusiveLock

2004-09-28 Thread Tom Lane
Achilleus Mantzios <[EMAIL PROTECTED]> writes: > Whats the purpose of the AccessExclusiveLock on parent table? We're adding a trigger to it. regards, tom lane ---(end of broadcast)--- TIP 8: explain analyze is your friend

[SQL] CHECK col A not NULL if col B='x'

2004-09-28 Thread T E Schmitz
Hello, Is it possible to set up a table CHECK, which ensures that column A is NOT NULL if column B = 'x' ? -- Regards/Gruß, Tarlika Elisabeth Schmitz ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (s

Re: [SQL] Best way to know if there is a row

2004-09-28 Thread Achilleus Mantzios
O Martin Marques έγραψε στις Sep 28, 2004 : > I have a bunch of queries in a system I'm finishing, and I bumped with a > question on performace. > Which is the best way to solve this: > > I need to know if there is at least one row in the relation that comes from a > determinated query. Which i

[SQL] Best way to know if there is a row

2004-09-28 Thread Martin Marques
I have a bunch of queries in a system I'm finishing, and I bumped with a question on performace. Which is the best way to solve this: I need to know if there is at least one row in the relation that comes from a determinated query. Which is the best way to do this: (a) Build the query with "SEL

[SQL] FOREIGN KEY and AccessExclusiveLock

2004-09-28 Thread Achilleus Mantzios
Hi, all the below are for PostgreSQL 7.4.2. I noticed that during ALTER TABLE kid ADD CONSTRAINT "parcon" FOREIGN KEY (parid) on parent(id) pgsql tries to acquire an AccessExclusiveLock on *both* kid (which is pretty natural since it adheres with the docs, and it is an alter command) *and* pare