Re: [SQL] pg_dump using SQL

2008-03-19 Thread Preston Landers
Yusnel Rojas Garc?a([EMAIL PROTECTED])@2008.03.18 11:45:03 -0800: > Hi everyone > > Is there any way to do what pg_dump does?, I mean, get the structure of a > table in a database (ex: CREATE TABLE ...) > If you want to programmaticly discover the elements in a database schema then you can alway

Re: [SQL] Date and filling issues

2008-03-19 Thread Rodrigo E. De León Plicet
On 3/19/08, Christopher Crews <[EMAIL PROTECTED]> wrote: > and what I'm trying to do is fill in the missing dates with sales values of 0. create or replace function gen_dates(sd date, ed date) returns setof date as $$ select $1 + i from generate_series(0, $2 - $1) i; $$ language sql immutable; se

Re: [SQL] compare 2 tables in sql

2008-03-19 Thread Tena Sakai
Fantastic! Many thanks. Regards, Tena Sakai -Original Message- From: [EMAIL PROTECTED] on behalf of Jonah H. Harris Sent: Wed 3/19/2008 3:39 PM To: Tena Sakai Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] compare 2 tables in sql On Wed, Mar 19, 2008 at 1:56 PM, Tena Sakai <[EMAIL P

Re: [SQL] Date and filling issues

2008-03-19 Thread Osvaldo Kussama
2008/3/19, Christopher Crews <[EMAIL PROTECTED]>: > Hi All, > I'm not quite sure how to phrase this, but essentially my company has me > working on some reports and I have some charts associated with the SQL > results. > > My current query is: > > select > transaction_date as date, > sum(sa

Re: [SQL] compare 2 tables in sql

2008-03-19 Thread Jonah H. Harris
On Wed, Mar 19, 2008 at 1:56 PM, Tena Sakai <[EMAIL PROTECTED]> wrote: > Is there a sql way to compare (in a diff/cmp sense) > 2 tables? For example, SELECT * FROM foo EXCEPT SELECT * FROM moo; -- Jonah H. Harris, Sr. Software Architect | phone: 732.331.1324 EnterpriseDB Corporation | fax: 73

[SQL] Date and filling issues

2008-03-19 Thread Christopher Crews
Hi All, I'm not quite sure how to phrase this, but essentially my company has me working on some reports and I have some charts associated with the SQL results. My current query is: select transaction_date as date, sum(sale_amount) as sales from ej_transaction where transaction_date

Re: [SQL] compare 2 tables in sql

2008-03-19 Thread Dean Gibson (DB Administrator)
On 2008-03-19 10:56, Tena Sakai wrote: Hi Everybody, Is there a sql way to compare (in a diff/cmp sense) 2 tables? For example, create table foo as [select bla bla bla]; create table moo as [select bla bla bla]; How would I go about knowing foo and moo are identical (or not)? Any

Re: [SQL] compare 2 tables in sql

2008-03-19 Thread Volkan YAZICI
On Wed, 19 Mar 2008, "Tena Sakai" <[EMAIL PROTECTED]> writes: > Is there a sql way to compare (in a diff/cmp sense) > 2 tables? You can diff "pg_dump --schema-only" output of the related tables. (I attached an ad-hoc script once I wrote to use for such stuff.) I don't know about [php]pgadmin, but

[SQL] compare 2 tables in sql

2008-03-19 Thread Tena Sakai
Hi Everybody, Is there a sql way to compare (in a diff/cmp sense) 2 tables? For example, create table foo as [select bla bla bla]; create table moo as [select bla bla bla]; How would I go about knowing foo and moo are identical (or not)? Any pointer would be appreciated. Tena

Re: [SQL] Create on insert a unique random number

2008-03-19 Thread D'Arcy J.M. Cain
On Wed, 19 Mar 2008 08:28:28 -0700 Steve Midgley <[EMAIL PROTECTED]> wrote: > I'm not following this line. Maybe we're talking about two different > things here.. I don't know if Lance is using "CRUD" methodology per se, > but that's a well accepted web approach and uses (generally) serial > pri

Re: [SQL] Create on insert a unique random number

2008-03-19 Thread Steve Midgley
At 06:47 AM 3/19/2008, D'Arcy J.M. Cain wrote: But your suggestion was to base this key on the serial primary key so where is your index collision protection? You are going to get collisions on both the serial key and, to a lesser extent, your generated one. Besides, has anyone ever demonstrated

Re: [SQL] Create on insert a unique random number

2008-03-19 Thread D'Arcy J.M. Cain
On Tue, 18 Mar 2008 13:57:39 -0700 Steve Midgley <[EMAIL PROTECTED]> wrote: > At 12:36 PM 3/18/2008, D'Arcy J.M. Cain wrote: > >On Tue, 18 Mar 2008 12:23:35 -0700 > >Steve Midgley <[EMAIL PROTECTED]> wrote: > > > 1) Create a second field (as someone recommend on this list) that > > is an > > > MD5

Re: [SQL] Create on insert a unique random number

2008-03-19 Thread hubert depesz lubaczewski
On Tue, Mar 18, 2008 at 01:40:42PM -0500, Campbell, Lance wrote: > This is not a security approach. It is more about not giving obvious > access to people that want to mess around. 1. keep primary key using standard serial. it will make your life a bit simpler. 2. add column for text random ident