[SQL] unreferenced primary keys: garbage collection

2001-01-19 Thread Forest Wilkinson
I have a database in which five separate tables may (or may not) reference any given row in a table of postal addresses. I am using the primary / foreign key support in postgres 7 to represent these references. My problem is that, any time a reference is removed (either by deleting or updating a

Re: [SQL] Trouble with subqueries

2001-01-19 Thread Robert B. Easter
Stuff like this is possible in 7.1: SELECT m.name, m.length, count(r.rating) AS fives FROM movies m LEFT JOIN (SELECT * FROM ratings WHERE rating = 5) AS r ON m.name = r.name GROUP BY m.name, m.length; I think that would work. You'd want to try different queries with EXPLAIN to see what looks

Re: [SQL] Trouble with subqueries

2001-01-19 Thread Jussi Vainionpää
Yury Don wrote: > If I understand correctly it must looks like this: > SELECT name, length, > (SELECT count(*) >FROM ratings >WHERE rating='5' >and rating.name=movies.name) as fives > FROM movies > WHERE name=rname; This results in several rows for eac

Re: [SQL] Correct Syntax for alter table ..add constraint

2001-01-19 Thread Najm Hashmi
Josh Berkus wrote: > Najm, > > > references age_list(id); > > And I get the following error: > > flipr=# alter table users > > flipr-# add constraint age_fk foreign key(age) references > > age_list(id); > > NOTICE: ALTER TABLE ... ADD CONSTRAINT will create > > implicit trigger(s) > > for FOREIG

Re: [SQL] Correct Syntax for alter table ..add constraint

2001-01-19 Thread Josh Berkus
Najm, > references age_list(id); > And I get the following error: > flipr=# alter table users > flipr-# add constraint age_fk foreign key(age) references > age_list(id); > NOTICE: ALTER TABLE ... ADD CONSTRAINT will create > implicit trigger(s) > for FOREIGN KEY check(s) > ERROR: referential i

[SQL] Correct Syntax for alter table ..add constraint

2001-01-19 Thread Najm Hashmi
Hi All, What is the correct syntax for adding a foreign key constraint from the command line. I am using v7.1 beta3. I am doing the follwoing: alter table users add constraint age_fk foreign key(age) references age_list(id); And I get th

[SQL] (No Subject)

2001-01-19 Thread Tony Mantana
Hello, I have visited your web site and found very interesting and informative. I would like to know: What is a BLOB Field and can you give a example of one? I hope to hear from you soon Get your small business started at Lycos Small Business at http://www.lycos.com/business/mail.html

Re: [SQL] SELECT FROM SELECT

2001-01-19 Thread Tom Lane
"Aleksey V. Kurinov" <[EMAIL PROTECTED]> writes: > Does Postrges provide "Select * from Select * from t1" construction ? In 7.1. But you have to spell it per the SQL spec: select * from (select * from t1) as foo; The parentheses and alias name are not optional.

Re: [SQL] Where can i get Pgaccess

2001-01-19 Thread Oliver Elphick
Ramesh H R wrote: >Hello everyone, >Please can anyone tell me, where i can get Pgaccess query tool It is in the PostgreSQL source at src/bin/pgaccess/ See also http://www.flex.ro/pgaccess -- Oliver Elphick[EMAIL PROTECTED] Isle of Wight

Re: [SQL] Distributed database ?

2001-01-19 Thread D'Arcy J.M. Cain
Thus spake guard > how to run "select from databaseA:tabl1 ,databaseB:table2 " You can't. You have to have two databases open and do it yourself. I use Python and often do things like this. import pg adb = pg.DB('dbase_a') bdb = pg.DB('dbase_b') row = adb.get('table_a', 1)# second argumen

[SQL] Where can i get Pgaccess

2001-01-19 Thread Ramesh H R
Hello everyone, Please can anyone tell me, where i can get Pgaccess query tool Regards, -- Ramesh HR Trainee Engineer EASi Technologies 213, 3rd Main, 4th Cross Chamrajpet, Bangalore - 560 018 India Ph.: 660 1086 / 660 2365 / 667 2984 Extn.: 155 Facsimile: 667 5274 www.easi.soft.net

Re: [SQL] notice on transaction abort?

2001-01-19 Thread Kovacs Zoltan Sandor
On Thu, 18 Jan 2001, Stephan Szabo wrote: > Well, you should have gotten an error message from the statement that was > in error in any case, but maybe a message on the commit/end that says > that the transaction was aborted due to errors would be nice. Or both. Zoltan

Re: [SQL] primary key and indexing

2001-01-19 Thread Richard Huxton
Sorry for lack of proper quoting, you might find it useful to From: "Sharmad Naik" <[EMAIL PROTECTED]> I m sorry If anyone has already asked this Q earlier I wanted to know Q1. Whether I can have another key on which the table is indexed even though i have a primary key..Then how would the

Re: [SQL] Trouble with subqueries

2001-01-19 Thread Yury Don
Hello Jussi, Once, Friday, January 19, 2001, 12:34:50 PM, you wrote: JV> I have the following two tables: JV> create table movies ( JV> name varchar(80), JV> info varchar(80), JV> length int, JV> primary key (name) JV> ); JV> create table ratings ( JV> name varchar(80), JV> userid

Re: [SQL] Trouble with subqueries

2001-01-19 Thread Tomas Berndtsson
Jussi Vainionpää <[EMAIL PROTECTED]> writes: > SELECT name, length, fives > FROM movies, >(SELECT name as rname, >count(*) as fives > FROM ratings > WHERE rating='5' > GROUP BY name) > WHERE name=rname; > > but in PostgreSQL 7 it just giv

[SQL] Trouble with subqueries

2001-01-19 Thread Jussi Vainionpää
I have the following two tables: create table movies ( name varchar(80), info varchar(80), length int, primary key (name) ); create table ratings ( name varchar(80), userid varchar(10), rating char(1), foreign key (name) references movies, primary key(name, userid) ); The tabl

[SQL] SELECT FROM SELECT

2001-01-19 Thread Aleksey V. Kurinov
Hi, All !! Does Postrges provide "Select * from Select * from t1" construction ? I use Postrges v.7.0.3 and get "ERROR: parser: parse error at or near "select" response for such request. Thanks, Leksey

[SQL] Indices

2001-01-19 Thread Nikolaj Lundsgaard
Maybe a wrong mailinglist to ask this, but... Are there any plans on writing a chapter in the documentation about the implementation of indices. I know from M$ SQL Server that it is no picnic determining which indices are useful, and thick books can be written on how to make the right indices f

[SQL] primary key and indexing

2001-01-19 Thread Sharmad Naik
I m sorry If anyone has already asked this Q earlier     I wanted to know   Q1. Whether I can have another key on which the table is indexed even though i have a primary key..Then how would the data be accessed according to primary key or the indexed key of my choice or i can index as per m