Thread: PgAdmin errors

PgAdmin errors

From
"Hall, Samuel L (Sam)"
Date:

When I try to run SQL from PgAdmin : CREATE TABLE tse_history_old LIKE tse_history INCLUDING ALL WITH OIDS

I get this  error

ERROR:  syntax error at or near "LIKE"

LINE 2: CREATE TABLE tse_history_old LIKE tse_history INCLUDING ALL ...

 

testing, I find that using the word “LIKE” always causes errors

 

"PostgreSQL 9.3.0 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit"

Running PgAdmin on Windows 7 64 bit

 

What I need to do is copy a table completely, all data, indexes, keys

 

Re: PgAdmin errors

From
John R Pierce
Date:
On 3/26/2014 12:32 PM, Hall, Samuel L (Sam) wrote:

When I try to run SQL from PgAdmin : CREATE TABLE tse_history_old LIKE tse_history INCLUDING ALL WITH OIDS

I get this  error

ERROR:  syntax error at or near "LIKE"

LINE 2: CREATE TABLE tse_history_old LIKE tse_history INCLUDING ALL ...


from the manual, it appears LIKE belongs in parenthesis.

CREATE TABLE tse_history_old (LIKE tse_history INCLUDING ALL) WITH OIDS



-- 
john r pierce                                      37N 122W
somewhere on the middle of the left coast

Re: PgAdmin errors

From
"Hall, Samuel L (Sam)"
Date:

That doesn’t help. Even this CREATE TABLE tse_history_old (LIKE tse_history) gives an error

 

From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of John R Pierce
Sent: Wednesday, March 26, 2014 2:43 PM
To: pgsql-general@postgresql.org
Subject: Re: [GENERAL] PgAdmin errors

 

On 3/26/2014 12:32 PM, Hall, Samuel L (Sam) wrote:

When I try to run SQL from PgAdmin : CREATE TABLE tse_history_old LIKE tse_history INCLUDING ALL WITH OIDS

I get this  error

ERROR:  syntax error at or near "LIKE"

LINE 2: CREATE TABLE tse_history_old LIKE tse_history INCLUDING ALL ...


from the manual, it appears LIKE belongs in parenthesis.

CREATE TABLE tse_history_old (LIKE tse_history INCLUDING ALL) WITH OIDS




-- 
john r pierce                                      37N 122W
somewhere on the middle of the left coast

Re: PgAdmin errors

From
John R Pierce
Date:
On 3/26/2014 12:58 PM, Hall, Samuel L (Sam) wrote:
That doesn’t help. Even this CREATE TABLE tse_history_old (LIKE tse_history) gives an error

the exact same error ?



-- 
john r pierce                                      37N 122W
somewhere on the middle of the left coast

Re: PgAdmin errors

From
"Hall, Samuel L (Sam)"
Date:

ERROR:  syntax error at or near "LIKE"

LINE 2: CREATE TABLE tse_history_old (LIKE tse_history)

                                                                              ^

 

From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of John R Pierce
Sent: Wednesday, March 26, 2014 3:02 PM
To: pgsql-general@postgresql.org
Subject: Re: [GENERAL] PgAdmin errors

 

On 3/26/2014 12:58 PM, Hall, Samuel L (Sam) wrote:

That doesn’t help. Even this CREATE TABLE tse_history_old (LIKE tse_history) gives an error


the exact same error ?




-- 
john r pierce                                      37N 122W
somewhere on the middle of the left coast

Re: PgAdmin errors

From
Tom Lane
Date:
"Hall, Samuel L (Sam)" <sam.hall@alcatel-lucent.com> writes:
> ERROR:  syntax error at or near "LIKE"
> LINE 2: CREATE TABLE tse_history_old (LIKE tse_history)

You're certain the server you're talking to is 9.3?
("SELECT version()" is a good way to be sure.)

            regards, tom lane


Re: PgAdmin errors

From
"Hall, Samuel L (Sam)"
Date:
Yes
"PostgreSQL 9.3.0 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit"

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Wednesday, March 26, 2014 4:03 PM
To: Hall, Samuel L (Sam)
Cc: John R Pierce; pgsql-general@postgresql.org
Subject: Re: [GENERAL] PgAdmin errors

"Hall, Samuel L (Sam)" <sam.hall@alcatel-lucent.com> writes:
> ERROR:  syntax error at or near "LIKE"
> LINE 2: CREATE TABLE tse_history_old (LIKE tse_history)

You're certain the server you're talking to is 9.3?
("SELECT version()" is a good way to be sure.)

            regards, tom lane


Re: PgAdmin errors

From
Adrian Klaver
Date:
On 03/26/2014 02:13 PM, Hall, Samuel L (Sam) wrote:
> Yes
> "PostgreSQL 9.3.0 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit"

So what happens when you run the command from psql ?




--
Adrian Klaver
adrian.klaver@aklaver.com


Re: PgAdmin errors

From
Alvaro Herrera
Date:
Hall, Samuel L (Sam) wrote:
> ERROR:  syntax error at or near "LIKE"
> LINE 2: CREATE TABLE tse_history_old (LIKE tse_history)
>                                                                               ^

Note it says this is on line 2.  What have you got in the previous line?
(psql has \p to show existing query buffer contents but I don't know if
pgadmin has such a facility).

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


Re: PgAdmin errors

From
John R Pierce
Date:
On 3/26/2014 1:07 PM, Hall, Samuel L (Sam) wrote:

ERROR:  syntax error at or near "LIKE"

LINE 2: CREATE TABLE tse_history_old (LIKE tse_history)


thats the syntax from http://www.postgresql.org/docs/current/static/sql-createtable.html

try it in psql instead of pgadmin ?


earlier, you mentioned...

"PostgreSQL 9.3.0 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit"


BTW, you really should update that database server to 9.3.4


 What I need to do is copy a table completely, all data, indexes, keys


COPY TABLE ... (LIKE ...)   will copy fields, constraints, and indexes (given that you used INCLUDING ALL), but it doesn't copy data.