problem trying to create a temp table

Поиск
Список
Период
Сортировка
Искать

problem trying to create a temp table

От:
<mgould@isstrucksoftware.net>
Дата:
ALL,
 
Using 9.1.2 on Windows 7 X64 for development.
 
I'm trying to create a temporary table used to store session variables for each user when they login.  I'm moving from SQL Anywhere and they have a CREATE VARIABLE which does this, so I thought a temp table would work fine, especially since each user will have their own copy.
 
CREATE  TEMP TABLE iss.sessionsettings
(
  VarName character varying(20) NOT NULL,
  value character varying(128),
  CONSTRAINT pk_sessionsettings_varname PRIMARY KEY (VarName )
)
WITH (
  OIDS=FALSE
);
ALTER TABLE iss.sessionsettings
  OWNER TO postgres;
 
When I try and run this I get the following error message.
 
ERROR:  cannot create temporary relation in non-temporary schema

********** Error **********
ERROR: cannot create temporary relation in non-temporary schema
SQL state: 42P16
 
What do I need to do to create temporary tables to the schema.  I guess I could create a separate schema for temp tables if needed.
 
 
Best Regards
 
Michael Gould
Intermodal Software Solutions, LLC
904-226-0978

Re: problem trying to create a temp table

От:
Richard Huxton <dev@archonet.com>
Дата:
On 24/02/12 13:26, mgould@isstrucksoftware.net wrote:

> ALL,
> Using 9.1.2 on Windows 7 X64 for development.
> I'm trying to create a temporary table used to store session variables
>  CREATE TEMP TABLE iss.sessionsettings

> When I try and run this I get the following error message.
> ERROR: cannot create temporary relation in non-temporary schema
Temp tables get their own schema, and each session (connection) gets
its own temp schema. So - don't qualify them by schema.

-- 
   Richard Huxton
   Archonet Ltd

Re: problem trying to create a temp table

От:
<mgould@isstrucksoftware.net>
Дата:
How do I access = it.  I just did that and when I try and access it with a   ERROR:  relation "sessionsetting" does not existLINE 1: selec= t * from "sessionsetting"       &nbs= p;            &= nbsp; ^ ********** Error ********** ERROR: relation "sessionsetting" does not existSQL state: 42P01Character: 15    or ERROR: relation "sessionsetting" does not existLINE 1: select * fr= om "sessionsetting"^ ********** Error ********** ERROR: relation sessionsetting does not existSQL state: 42P01C= haracter: 15   Best Regards, Michael Gould Intermodal Software Solutions, LLC 904-226-0978    
-------- Original Message --------Subject: Re:= [GENERAL] problem trying to create a temp tableFrom: Richard Huxton &l= t;dev@archonet.com>Date: Fri= , February 24, 2012 6:32 amTo: mgould@isstrucksoftware.netCc: "pgsql-general@postgresql.org" <pgsql-general@postgresql.org>= On 24/02/12 13:26, mgould@is= strucksoftware.net wrote:> ALL,> Using 9.1.2 on Windo= ws 7 X64 for development.> I'm trying to create a temporary table us= ed to store session variables> CREATE TEMP TABLE iss.sessionsettings= > When I try and run this I get the following error message.= > ERROR: cannot create temporary relation in non-temporary schemaTem= p tables get their own schema, and each session (connection) getsits ow= n temp schema. So - don't qualify them by schema.-- Richard Hux= tonArchonet Ltd=

Re: problem trying to create a temp table

От:
Andrew Gould <andrewlylegould@gmail.com>
Дата:
On Fri, Feb 24, 2012 at 7:32 AM, Richard Huxton  wrote:
> On 24/02/12 13:26, mgould@isstrucksoftware.net wrote:
>
>> ALL,
>> Using 9.1.2 on Windows 7 X64 for development.
>> I'm trying to create a temporary table used to store session variables
>>  CREATE TEMP TABLE iss.sessionsettings
>
>
>> When I try and run this I get the following error message.
>> ERROR: cannot create temporary relation in non-temporary schema
>
> Temp tables get their own schema, and each session (connection) gets
> its own temp schema. So - don't qualify them by schema.
>
> --
>  Richard Huxton
>  Archonet Ltd
>

Is that to avoid naming conflicts between simultaneous users?

Andrew

Re: problem trying to create a temp table

От:
Andrew Gould <andrewlylegould@gmail.com>
Дата:
Вложения:
On Fri, Feb 24, 2012 at 7:36 AM, <mgould@isstrucksoftware.net> wrote:
How do I access it.  I just did that and when I try and access it with a
 
ERROR:  relation "sessionsetting" does not exist
LINE 1: select * from "sessionsetting"
                      ^

********** Error **********
ERROR: relation "sessionsetting" does not exist
SQL state: 42P01
Character: 15
 
  or
ERROR: relation "sessionsetting" does not exist
LINE 1: select * from "sessionsetting"
^

********** Error **********
ERROR: relation sessionsetting does not exist
SQL state: 42P01
Character: 15
 
Best Regards,
Michael Gould
Intermodal Software Solutions, LLC
 
 
-------- Original Message --------
Subject: Re: [GENERAL] problem trying to create a temp table
From: Richard Huxton <dev@archonet.com>
Date: Fri, February 24, 2012 6:32 am
To: mgould@isstrucksoftware.net
Cc: "pgsql-general@postgresql.org" <pgsql-general@postgresql.org>

On 24/02/12 13:26, mgould@isstrucksoftware.net wrote:

> ALL,
> Using 9.1.2 on Windows 7 X64 for development.
> I'm trying to create a temporary table used to store session variables
> CREATE TEMP TABLE iss.sessionsettings

> When I try and run this I get the following error message.
> ERROR: cannot create temporary relation in non-temporary schema
Temp tables get their own schema, and each session (connection) gets
its own temp schema. So - don't qualify them by schema.

--
Richard Huxton
Archonet Ltd

Try to access the table without putting the table name in double quotes.  Does that make a difference?

Andrew

Re: problem trying to create a temp table

От:
<mgould@isstrucksoftware.net>
Дата:
Andrew,
 
That is acutally what the second run was supposed to be.  I copied the
original on instead of the second instance, but the results were the
same.


Michael Gould
Intermodal Software Solutions, LLC
904-226-0978
 
 
-------- Original Message --------
Subject: Re: [GENERAL] problem trying to create a temp table
From: Andrew Gould 
Date: Fri, February 24, 2012 6:41 am
To: mgould@isstrucksoftware.net
Cc: Richard Huxton , "pgsql-general@postgresql.org"


On Fri, Feb 24, 2012 at 7:36 AM,  wrote:
How do I access it.  I just did that and when I try and access it with a

 
ERROR:  relation "sessionsetting" does not exist
LINE 1: select * from "sessionsetting"
                      ^

********** Error **********
ERROR: relation "sessionsetting" does not exist
SQL state: 42P01
Character: 15
  
  or 
ERROR: relation "sessionsetting" does not exist
LINE 1: select * from "sessionsetting"
^

********** Error **********
ERROR: relation sessionsetting does not exist
SQL state: 42P01
Character: 15

 
Best Regards,

Michael Gould
Intermodal Software Solutions, LLC
904-226-0978
 
 

-------- Original Message --------
Subject: Re: [GENERAL] problem trying to create a temp table
From: Richard Huxton 
Date: Fri, February 24, 2012 6:32 am
To: mgould@isstrucksoftware.net
Cc: "pgsql-general@postgresql.org" 

On 24/02/12 13:26, mgould@isstrucksoftware.net wrote:

> ALL,
> Using 9.1.2 on Windows 7 X64 for development.
> I'm trying to create a temporary table used to store session variables
> CREATE TEMP TABLE iss.sessionsettings

> When I try and run this I get the following error message.
> ERROR: cannot create temporary relation in non-temporary schema
Temp tables get their own schema, and each session (connection) gets
its own temp schema. So - don't qualify them by schema.

-- 
Richard Huxton
Archonet Ltd







Try to access the table without putting the table name in double quotes.
 Does that make a difference?

Andrew

Re: problem trying to create a temp table

От:
Richard Huxton <dev@archonet.com>
Дата:
On 24/02/12 13:36, mgould@isstrucksoftware.net wrote:
> How do I access it. I just did that and when I try and access it with a
> ERROR: relation "sessionsetting" does not exist
> LINE 1: select * from "sessionsetting"

=> CREATE SCHEMA foo;
CREATE SCHEMA
=> CREATE TABLE foo.table1 (id int);
CREATE TABLE
=> SET search_path = foo;
SET
=> INSERT INTO table1 VALUES (1),(2),(3);
INSERT 0 3
=> CREATE TEMP TABLE table1 (id int);
CREATE TABLE
=> INSERT INTO table1 VALUES (4),(5),(6);
INSERT 0 3
=> SELECT * FROM table1;
  id
----
   4
   5
   6
(3 rows)
=> DROP TABLE table1;
DROP TABLE
=> SELECT * FROM table1;
  id
----
   1
   2
   3
(3 rows)

Try "SELECT * FROM pg_namespace" to see the various temp schemas being 
created.

-- 
   Richard Huxton
   Archonet Ltd

Re: problem trying to create a temp table

От:
Richard Huxton <dev@archonet.com>
Дата:
On 24/02/12 13:37, Andrew Gould wrote:
> On Fri, Feb 24, 2012 at 7:32 AM, Richard Huxton  wrote:
>>
>> Temp tables get their own schema, and each session (connection) gets
>> its own temp schema. So - don't qualify them by schema.
>
> Is that to avoid naming conflicts between simultaneous users?

Yes. I believe it also invisibly adds it to your search_path too, the 
same as it does with the pg_catalog schema.

-- 
   Richard Huxton
   Archonet Ltd

Re: problem trying to create a temp table

От:
Adrian Klaver <adrian.klaver@gmail.com>
Дата:
On Friday, February 24, 2012 5:46:06 am mgould@isstrucksoftware.net wrote:
> Andrew,
> 
> That is acutally what the second run was supposed to be.  I copied the
> original on instead of the second instance, but the results were the
> same.

Are you doing all this in the same session?:

test(5432)postgres=#create temp table temp_test(id int, fld_1 text);
CREATE TABLE

test(5432)postgres=#SELECT * from temp_test;
 id | fld_1 
----+-------
(0 rows)

If so what are the exact commands you are executing?

> 
> 
> Michael Gould
> Intermodal Software Solutions, LLC
> 904-226-0978
> 

-- 
Adrian Klaver
adrian.klaver@gmail.com
FAQ