All right children. Recess is over, get back to work.
-Original Message-
From: pgsql-general-ow...@postgresql.org
[mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Ed Koch
Sent: Wednesday, September 16, 2009 8:27 AM
To: 'mgai...@hotmail.com'; 'g...@seespotcode.net'
Cc: 'dmag...@gm
Create a plpgsql function that reformats your row as an array.
Example:
I have a table named task_parameter with three columns:
Table "camera.task_parameter"
Column | Type | Modifiers
--+-
change t.date2< dates.date to t.date2+0= dates.date) and t.date2+0mailto:[EMAIL PROTECTED] On Behalf Of Jeff Amiel
Sent: Thursday, September 25, 2008 10:24 AM
To: pgsql-general@postgresql.org
Subject: [GENERAL] The planner hates me.
"PostgreSQL 8.2.4 on i386-pc-solaris2.10, compiled by GCC gcc (G
minor refinement on suggestion:
-- CTAS (create table as) is easiest way to create table with same
structure
create table foo as select * from orig_table;
-- truncate is much more efficient than delete
truncate orig_table;
-- unchanged
insert into orig_table select * from foo;
-- recompute statist
This will also work as long as the table isn't large or product is
indexed.
actually,its more likely product is indexed that criteria_1 or _2...
Note: in this case when there is a tie one provider is arbitrarily
selected
select mx.product,
mx.max_criteria_1,
(select provider fro
if criteria_1 and _2 are indexed:
select
mx.product,
p1.provider as best_provider_1,
mx.max_criteria_1,
p2.provider as best_provider_2
mx.max_criteria_2
from
(select
product,
max(criteria_1) as max_criteria_1,
max(criteria_2) as max_criteria_2
from
products_provi
Hoover, Jeffrey would like to recall the message, "[GENERAL] Complicated GROUP
BY".
Why are there too many to fix with ALTER?
Use SQL and the data dictionary to generate the DDL and pipe it into
psql (or spool it to disk and use that file as a sql script):
psql your_db_name -t -c "select 'alter table '||t.tablename||' rename
\"'||c.column_name||'\" to '||lower(c.column_name)||