Thread: Temporary and permanent tables with same name

Temporary and permanent tables with same name

From
"Vilson farias"
Date:
Greetings,
 
  I've been doing some temporary tables and I created one with the same name of a permanent table. Maybe you should avoid temporary tablem creation for this case.
 
Best regards.
 
 
bxs=# CREATE TABLE test (x INT4);
CREATE
bxs=# SELECT CAST('45 SECONDS' AS INTERVAL) INTO TEMP test;
SELECT
bxs=# SELECT * FROM test;
 ?column?
----------
 00:00:45
(1 row)
 
bxs=# \d test
          Table "test"
 Attribute |  Type   | Modifier
-----------+---------+----------
 x         | integer |
 
bxs=# INSERT INTO test VALUES (1);
ERROR:  Attribute '?column?' is of type 'interval' but expression is of type 'int4'
        You will need to rewrite or cast the expression
 
--------------------------------------------------------------------------------
José Vilson de Mello de Farias
Software Engineer
 
Dígitro Tecnologia Ltda - www.digitro.com.br
APC - Customer Oriented Applications
E-mail: vilson.farias@digitro.com.br
Tel.: +55 48 281 7158
ICQ 11866179

Re: Temporary and permanent tables with same name

From
Tom Lane
Date:
"Vilson farias" <vilson.farias@digitro.com.br> writes:
>   I've been doing some temporary tables and I created one with the same nam=
> e of a permanent table. Maybe you should avoid temporary tablem creation fo=
> r this case.=20

That's generally considered a feature, not a bug.

            regards, tom lane

Re: Temporary and permanent tables with same name

From
Curt Sampson
Date:
On Wed, 5 Feb 2003, Vilson farias wrote:

>   I've been doing some temporary tables and I created one with the
> same name of a permanent table. Maybe you should avoid temporary
> tablem creation for this case.
> ...
>
> bxs=# CREATE TABLE test (x INT4);
> CREATE
> bxs=# SELECT CAST('45 SECONDS' AS INTERVAL) INTO TEMP test;

Yes, this is a great feature, isn't it? I use it all the time for creating
a copy of a table local to a connection and running various tests on it.
Then it just vanishes when I disconnect.

cjs
--
Curt Sampson  <cjs@cynic.net>   +81 90 7737 2974   http://www.netbsd.org
    Don't you know, in this new Dark Age, we're all light.  --XTC