From: | Samuel Gendler <sgendler(at)ideasculptor(dot)com> |
---|---|
To: | Philip Couling <phil(at)pedal(dot)me(dot)uk> |
Cc: | Rehan Saleem <pk_rehan(at)yahoo(dot)com>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: How To Create Temporary Table inside a function |
Date: | 2012-03-02 22:17:14 |
Message-ID: | CAEV0TzBvnjXkk3RBgQCNmXQos3c3OSF-6ofKLVdvurJDgkGAVw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, Mar 2, 2012 at 3:49 AM, Philip Couling <phil(at)pedal(dot)me(dot)uk> wrote:
> Hi Rehan
>
> I suggest attempting to drop the table before you create the temp table:
> DROP TABLE IF EXISTS table1;
>
> See:
> http://www.postgresql.org/docs/current/static/sql-droptable.html
>
>
> Also if you're using an actual TEMP table, PostgreSQL can automatically
> drop the table or just empty it once the transaction is committed:
> CREATE TEMP TABLE foo (columns...) ON COMMIT DROP;
> CREATE TEMP TABLE foo (columns...) ON COMMIT DELETE ROWS;
>
> See:
> http://www.postgresql.org/docs/current/static/sql-createtable.html
>
>
> As for filling the table, you have two options, INSERT ... SELECT ...
> Which is just the same syntax as you've used previously for MS SQL or
> create the table with data already in it it:
> CREATE TEMP TABLE foo ON COMMIT DROP AS SELECT ...
>
> See:
> http://www.postgresql.org/docs/current/static/sql-createtableas.html
>
> Hope this helps.
>
Rehan,
100% of the information in this email is available in the postgresql
documentation in locations where it would be trivially easy to find if any
attempt at all was made to look in the documentation prior to coming to the
mailing list for assistance.
It is fruitless to attempt to work as a database administrator or developer
if you do not first familiarize yourself with its documentation. The
mailing lists are here to assist users with difficult-to-solve problems,
not as substitute for reading the manual. Answering easily solved questions
takes limited resources away from users who may have more intractable
issues that they need assistance with.
I can't help but notice that this isn't even the first question you've
posed to which responses have included suggestions that you read the
documentation. Please consider taking our advice.
--sam
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2012-03-03 10:24:27 | Re: date arithmetic with columns |
Previous Message | Sandeep Reddy | 2012-03-02 19:41:31 | Re: Problems with ODBC connections |