problem trying to create a temp table

Started by Michael Gouldabout 14 years ago9 messagesgeneral
Jump to latest
#1Michael Gould
mgould@isstrucksoftware.net

Attachments:

top.letterheadimage/png; name=top.letterheadDownload+3-1
#2Richard Huxton
dev@archonet.com
In reply to: Michael Gould (#1)
Re: problem trying to create a temp table

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

#3Michael Gould
mgould@isstrucksoftware.net
In reply to: Richard Huxton (#2)
Re: problem trying to create a temp table

Attachments:

top.letterheadimage/png; name=top.letterheadDownload+3-1
#4Andrew Gould
andrewlylegould@gmail.com
In reply to: Richard Huxton (#2)
Re: problem trying to create a temp table

On Fri, Feb 24, 2012 at 7:32 AM, Richard Huxton <dev@archonet.com> 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

#5Andrew Gould
andrewlylegould@gmail.com
In reply to: Michael Gould (#3)
Re: problem trying to create a temp table

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
904-226-0978

-------- 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

Attachments:

top.letterheadimage/png; name=top.letterheadDownload+3-1
#6Michael Gould
mgould@isstrucksoftware.net
In reply to: Andrew Gould (#5)
Re: problem trying to create a temp table

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 <andrewlylegould@gmail.com>
Date: Fri, February 24, 2012 6:41 am
To: mgould@isstrucksoftware.net
Cc: Richard Huxton <dev@archonet.com>, "pgsql-general@postgresql.org"
<pgsql-general@postgresql.org>

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
904-226-0978

-------- 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

#7Richard Huxton
dev@archonet.com
In reply to: Michael Gould (#3)
Re: problem trying to create a temp table

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

#8Richard Huxton
dev@archonet.com
In reply to: Andrew Gould (#4)
Re: problem trying to create a temp table

On 24/02/12 13:37, Andrew Gould wrote:

On Fri, Feb 24, 2012 at 7:32 AM, Richard Huxton<dev@archonet.com> 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

#9Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Michael Gould (#6)
Re: problem trying to create a temp table

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