Re: [SQL] SQL query help?

2005-03-07 Thread Michael Fuhr
On Mon, Mar 07, 2005 at 04:22:15PM -, John McGough wrote: > +---+---++-+--+ > | ID | JobID | UserID | Finished | Comment | > +---+---++-+--+ This table output doesn't look like PostgreSQL's usual format. > but I keep getting MySQL err

Re: [SQL] SQL query help?

2005-03-07 Thread Keith Worthington
John McGough wrote: SELECT Count(*) FROM Work WHERE (UserID='user1' AND MAX(Finished)=0) Work:- +---+---++-+--+ | ID | JobID | UserID | Finished | Comment | +---+---++-+--+ | 1 | 1| user1 | 0 | ...| | 2

Re: [SQL] Postgres performance

2005-03-07 Thread Mauro Bertoli
> > Yes, you are rigth... my insert/update are very > simple > > and without problems and so I think to use > 'foreign > > key' coded to make faster/simpler the management > and > > don't overloading the db (and use exception code > > management )... but I had a problem with pgSQL > because > > ser

Re: [SQL] Postgres performance

2005-03-07 Thread Mauro Bertoli
> > No, I haven't foreign keys in the older version, > in > > that new I've it... however I manage relations > from > > app code (PHP)... > > Really ? > In my experience this is a sure way to get > inconsistencies slowly > creeping into your database, and you also get a load > of fun

Re: [SQL] [ADMIN] Postgres schema comparison.

2005-03-07 Thread Goulet, Dick
My favorite for this task is WinSql available from http://www.synametrics.com/SynametricsWebApp/WinSQL.jsp. It can compare the structure and content of the two tables. -Original Message- From: John DeSoi [mailto:[EMAIL PROTECTED] Sent: Monday, March 07, 2005 7:40 AM To: Stef Cc: pgsql-A

Re: [SQL] Postgres performance

2005-03-07 Thread Mauro Bertoli
--- PFC <[EMAIL PROTECTED]> wrote: > You mean, you have no foreign keys in your database ? > In SELECT they are definitely useful (think select > for update, isolation > level serializable...) No, I haven't foreign keys in the older version, in that new I've it... however I manage re

Re: [SQL] Simple delete takes hours

2005-03-07 Thread Lynwood Stewart
Another way to speed it up is to use bind variables. It sped my deletes up by a factor of 280/1. -- Lynwood "Thomas Mueller" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi there, > > I have a simple database: > > CREATE TABLE pwd_description ( > id SERIALNOT

[SQL] SQL query help?

2005-03-07 Thread John McGough
SELECT Count(*) FROM Work WHERE (UserID='user1' AND MAX(Finished)=0) Work:- +---+---++-+--+ | ID | JobID | UserID | Finished | Comment | +---+---++-+--+ | 1 | 1| user1 | 0 | ...| | 2 | 1|

Re: [SQL] drop view even with dependencies?

2005-03-07 Thread Michael Fuhr
On Mon, Mar 07, 2005 at 04:38:53PM -0500, Henry Ortega wrote: > Is there a way to drop a VIEW in postgres without > the need to drop all the dependencies? > Also with tables, can I drop a table even if there are multiple views > that depend on it? I'm not aware of a way. It could be argued

[SQL] drop view even with dependencies?

2005-03-07 Thread Henry Ortega
Is there a way to drop a VIEW in postgres without the need to drop all the dependencies? VIEW 3 | VIEW 2 | VIEW 1 In my case, VIEW 3 depends on VIEW 2, and VIEW 2 depends on VIEW 1. Is there a way to drop VIEW 3 without dropping VIEW 1 and 2? I tried CREATE OR REPLACE VIEW but replace wi

Re: [SQL] Links between rows in a table

2005-03-07 Thread PFC
The trouble with this approach is that for some ways of using this data you will need to worry about the ordering of of the values. Tradeoffs, always tradeoffs... It depends on the application. Note also that it eliminates duplicates ; moreover without such a condition, any relation A-B could

[SQL] Lambda expressions in SQL

2005-03-07 Thread KÖPFERL Robert
Coming from functional programming, I often wish to write something like that: (LAMDA "expesiveFcn"(x y z) as exfcn update "Tbl5" SET "Column" = exfcn ) In this case "expensiveFcn" is VOLATILE... Is there a way? At least: substituting the lambda by a select doesn't work with update as

Re: [ADMIN] [SQL] Postgres schema comparison.

2005-03-07 Thread Jim Buttafuoco
Stef, I use dblink to attach to both databases and query pg_namespace, pg_class, pg_attribute ... to get the diffs. See attached as an example. look for the dblink_connect lines to specify your database. You will need to install contrib/dblink. I used this with 7.4.X series and have NOT tes

Re: [SQL] Links between rows in a table

2005-03-07 Thread Bruno Wolff III
On Sun, Mar 06, 2005 at 20:26:50 +0100, PFC <[EMAIL PROTECTED]> wrote: > >>It would probably be better to always have either both or neither of > >>the symmetric relationships in the table. You could make a set of > >>triggers > >>to enforce this. > > Because your relation is symmetric,

Re: [SQL] [SOLVED] Postgres schema comparison.

2005-03-07 Thread Stef
John DeSoi mentioned : => I'm not sure you can use \d directly, but if you startup psql with the => -E option it will show you all the SQL it is using to run the \d => command. It should be fairly easy to get the strings you need from the => results of running a similar query. The psql source is

Re: [SQL] [ADMIN] Postgres schema comparison.

2005-03-07 Thread John DeSoi
On Mar 7, 2005, at 10:09 AM, Stef wrote: Is it possible to somehow pass the output of : "\d [TABLE NAME]" to this function? If not, what would return me consistent text that will describe the columns, indexes and primary keys of a table? I'm not sure you can use \d directly, but if you startup psql

Re: [ADMIN] [SQL] Postgres schema comparison.

2005-03-07 Thread Stef
Tom Lane mentioned : => > The problem I have with this, is that I have to run the command per table, => => Why? => => If the problem is varying order of table declarations, try 8.0's => pg_dump. Yes, this will solve the global schema check, but I will still need to split it into "per table" dump

Re: [SQL] simple update from select ??

2005-03-07 Thread Gary Stainburn
On Monday 07 March 2005 12:28 pm, you wrote: > Hi folks > > I've got a table of pieces of equipment. > One piece of equipment may be owned by another piece of equipment, > and may own multiple other pieces. > > To hold the relationship I have a piece_pieces table holding the > owner (pp_id) part id

Re: [ADMIN] [SQL] Postgres schema comparison.

2005-03-07 Thread Stef
Markus Schaber mentioned : => Some weeks ago, I posted here a script that uses psql to create split => dumps. Maybe you can reuse some of its logics to create per-table => md5sums for all tables in a database automatically. Thanks, but I've got something very similar to this already. I almost tho

Re: [SQL] [ADMIN] Postgres schema comparison.

2005-03-07 Thread Stef
John DeSoi mentioned : => Develop a function that builds a string describing the tables/schemas => you want to compare. Then have your function return the md5 sum of the => string as the result. This will give you a 32 character value you can => use to determine if there is a mismatch. OK, this

Re: [ADMIN] [SQL] Postgres schema comparison.

2005-03-07 Thread Tom Lane
Stef <[EMAIL PROTECTED]> writes: > Markus Schaber mentioned : > => But maybe a pg_dump --schema-only on all the databases, and then > => manually diffing the files may already fulfil your needs. > I've tested something similar, that seems to work ok for me for now : > pg_dump -s -t [TABLE] [DBNAME

Re: [SQL] [ADMIN] Postgres schema comparison.

2005-03-07 Thread Stef
[EMAIL PROTECTED] mentioned : => Are you just synching the schemas, or do you also need to synch the data? Schemas now, data later. To do the data part, I'm thinking of using slony, because it seems to be able to do pretty much everything I need from that side. But, unfortunately I can't even st

Re: [SQL] [ADMIN] Postgres schema comparison.

2005-03-07 Thread Richard_D_Levine
Are you just synching the schemas, or do you also need to synch the data? Rick John DeSoi

Re: [ADMIN] [SQL] Postgres schema comparison.

2005-03-07 Thread Markus Schaber
Hi, Stef, Stef schrieb: > The problem I have with this, is that I have to run the command per table, > and seeing that I have over 500 tables in each database, this takes quite a > long time. Some weeks ago, I posted here a script that uses psql to create split dumps. Maybe you can reuse some o

[SQL] Maintaining production DBs, making one schema look like the other

2005-03-07 Thread KÖPFERL Robert
OK, the usual thing: There exists a DB-schema. It is on one hand already in production usage. On the other hand it is still being developed as functions and non-structural stuff are concerned. I found out that EMS Database Comparer helps to replicate the schema differences in form of SQL-statement

Re: [ADMIN] [SQL] Postgres schema comparison.

2005-03-07 Thread Stef
Markus Schaber mentioned : => There are (at least) two independently developed pgdiff applications, => they can be found at: => => http://pgdiff.sourceforge.net/ => => http://gborg.postgresql.org/project/pgdiff/projdisplay.php Thanks a lot! => I did not try the first one, but the latter one wor

Re: [SQL] [ADMIN] Postgres schema comparison.

2005-03-07 Thread John DeSoi
On Mar 7, 2005, at 4:33 AM, Stef wrote: I have the wonderful job of re-synch'ing all the schemas out there not conforming to the master. I've looked everywhere for something that will help doing this. I'm specifically looking for a way to do a sumcheck or something similar on tables and/or schema

[SQL] simple update from select ??

2005-03-07 Thread Gary Stainburn
Hi folks I've got a table of pieces of equipment. One piece of equipment may be owned by another piece of equipment, and may own multiple other pieces. To hold the relationship I have a piece_pieces table holding the owner (pp_id) part id and the owned part ids (pp_part). I'v realised I can st

Re: [SQL] Postgres schema comparison.

2005-03-07 Thread Markus Schaber
Hi, Stef, Stef schrieb: > It will be a bonus to pick up exactly what is missing, but for now, just > identifying > differences is what I want to achieve. I'm using postgres 7.3 mostly, but > I may want to use this for 7.4 and 8.0 databases as well. > > Has anybody got some suggestions of what

[SQL] Postgres schema comparison.

2005-03-07 Thread Stef
Hi all, I've got a master database with many other databases that all have (or is supposed to have) the same exact same schema as the master database (the master database is basically an empty template database containing the schema definition). The problem is that none of the schemas actually