Thread: RE: [GENERAL] Re: More PostgreSQL stuff

RE: [GENERAL] Re: More PostgreSQL stuff

From
"Jackson, DeJuan"
Date:
> Martin Schulze wrote:
>   >Hi Oliver!
>   >
>   >I have some more questions wrt. PostgreSQL.
>
> Forwarded to PostgreSQL list, since I cannot answer them.
>
>   > . Why does pg_dump only write some SQL commands in capital letters
>   >   but not all?  I wonder if that's intentional.  Please look at
> the
>   >   following excerpt.  I would have expected CHAR, VARCHAR, INSERT
>   >   INTO, VALUES etc. to occur in capital letters.
>   >
>   >   CREATE TABLE zeitungen (name char(30), typ char(10), ...
>   >
>   >   insert into zeitungen values ('Mallorca Immobilien
> ',...
CAPS/no-CAPS are just a preference of the coder's of pg_dump.  If you
want you can go through the source of pg_dump and uppercase all the SQL
and recompile.

>   >
>   > . I wonder how one could add or remove columns from existing
> tables.
>   >
>   >   With mSQL this was possible with a trick.  You had to dump the
>   >   whole table but you could tell the dump program to add dummy
> fields
>   >   or to leave out existing fields.  Is there any such possibility
>   >   with PostgreSQL?
You can do a select into a temp table with the added columns, drop the
old table the rename the temp table to the old name.  You'll also have
to recreate your indexes, triggers, and rules.
        -DEJ

Re: [GENERAL] Re: More PostgreSQL stuff

From
Martin Schulze
Date:
Jackson, DeJuan wrote:
> > Martin Schulze wrote:
> >   >Hi Oliver!
> >   >
> >   >I have some more questions wrt. PostgreSQL.
> >
> > Forwarded to PostgreSQL list, since I cannot answer them.
> >
> >   > . Why does pg_dump only write some SQL commands in capital letters
> >   >   but not all?  I wonder if that's intentional.  Please look at
> > the
> >   >   following excerpt.  I would have expected CHAR, VARCHAR, INSERT
> >   >   INTO, VALUES etc. to occur in capital letters.
> >   >
> >   >   CREATE TABLE zeitungen (name char(30), typ char(10), ...
> >   >
> >   >   insert into zeitungen values ('Mallorca Immobilien
> > ',...
> CAPS/no-CAPS are just a preference of the coder's of pg_dump.  If you
> want you can go through the source of pg_dump and uppercase all the SQL
> and recompile.

Sure, I would do this, but it means work.  I might get it included in the
Debian package, but will it be included in the upstream package as well?

> >   > . I wonder how one could add or remove columns from existing tables.
> >   >
> >   >   With mSQL this was possible with a trick.  You had to dump the
> >   >   whole table but you could tell the dump program to add dummy fields
> >   >   or to leave out existing fields.  Is there any such possibility
> >   >   with PostgreSQL?

> You can do a select into a temp table with the added columns, drop the
> old table the rename the temp table to the old name.  You'll also have
> to recreate your indexes, triggers, and rules.

I understand.  Looks like PostgreSQL is more preconceived than
other databases.  I figure out how to do this, though.  I you would
have an example laying around I'd be very happy receiving it.


Thanks,

    Joey



--
A mathematician is a machine for converting coffee into theorems.