DROP TABLE Appears to Fail

Started by Rich Shepardalmost 15 years ago8 messagesgeneral
Jump to latest
#1Rich Shepard
rshepard@appl-ecosys.com

I cannot recall issuing a DROP TABLE command from psql that did not work,
but seem to have this as a new experience.

When I look at the database table list with '\d' I see

public | station_type | table | rshepard
public | station_type_statype_seq | sequence | rshepard

and I want to drop and recreate these with a typo fixed. But, the drop
commands do not appear to work:

# drop table station_type

# \d

public | station_type | table | rshepard
public | station_type_statype_seq | sequence | rshepard

I fail to see what I'm doing incorrectly and would appreciate a clue stick
to set me on the proper path.

TIA,

Rich

#2Andreas Brandl
ml@3.141592654.de
In reply to: Rich Shepard (#1)
Re: DROP TABLE Appears to Fail

Hi Rich,

it might be sufficient to add a semicolon to your drop statement:

# drop table station_type;

HTH,
Andy

----- Ursprüngliche Mail -----

Show quoted text

I cannot recall issuing a DROP TABLE command from psql that did not
work,
but seem to have this as a new experience.

When I look at the database table list with '\d' I see

public | station_type | table | rshepard
public | station_type_statype_seq | sequence | rshepard

and I want to drop and recreate these with a typo fixed. But, the drop
commands do not appear to work:

# drop table station_type

# \d

public | station_type | table | rshepard
public | station_type_statype_seq | sequence | rshepard

I fail to see what I'm doing incorrectly and would appreciate a clue
stick
to set me on the proper path.

TIA,

Rich

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Rick Genter
rick.genter@gmail.com
In reply to: Rich Shepard (#1)
Re: DROP TABLE Appears to Fail

Silly question, but did you try it with a semicolon after the drop table?

# drop table station_type;

I've noticed that if you are in the middle of a statement and issue a \
command, psql ignores the SQL you've typed in and just does the \ command.

On Tue, Jun 28, 2011 at 3:34 PM, Rich Shepard <rshepard@appl-ecosys.com>wrote:

I cannot recall issuing a DROP TABLE command from psql that did not work,
but seem to have this as a new experience.

When I look at the database table list with '\d' I see

public | station_type | table | rshepard
public | station_type_statype_seq | sequence | rshepard

and I want to drop and recreate these with a typo fixed. But, the drop
commands do not appear to work:

# drop table station_type

# \d

public | station_type | table | rshepard
public | station_type_statype_seq | sequence | rshepard

I fail to see what I'm doing incorrectly and would appreciate a clue stick
to set me on the proper path.

TIA,

Rich

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/**mailpref/pgsql-general&lt;http://www.postgresql.org/mailpref/pgsql-general&gt;

--
Rick Genter
rick.genter@gmail.com

#4Rich Shepard
rshepard@appl-ecosys.com
In reply to: Andreas Brandl (#2)
Re: DROP TABLE Appears to Fail

On Wed, 29 Jun 2011, Andy Firel wrote:

it might be sufficient to add a semicolon to your drop statement:
# drop table station_type;

Andy,

Actually, that's not true. On a whim I tried that and psql complained
about a syntax error at the initial 'd'.

Rich

#5Rich Shepard
rshepard@appl-ecosys.com
In reply to: Rick Genter (#3)
Re: DROP TABLE Appears to Fail

On Tue, 28 Jun 2011, Rick Genter wrote:

Silly question, but did you try it with a semicolon after the drop table?

Rick,

See my answer to Andy: that's incorrect syntax and psql complains.

I've noticed that if you are in the middle of a statement and issue a \
command, psql ignores the SQL you've typed in and just does the \ command.

But there is no continuation command just 'drop table <tablename>'.

Thanks,

Rich

#6Rick Genter
rick.genter@gmail.com
In reply to: Rich Shepard (#5)
Re: DROP TABLE Appears to Fail

After issuing the \d you are still in the middle of your command. Witness
the following copy/paste of a terminal session:

bash-3.2$ ./psql
Password:
psql (8.4.4)
Type "help" for help.

postgres=# create table foo (bar int);
CREATE TABLE
postgres=# drop table foo
postgres-# \d
List of relations
Schema | Name | Type | Owner
--------+------+-------+----------
public | foo | table | postgres
(1 row)

postgres-# drop table foo;
ERROR: syntax error at or near "drop"
LINE 2: drop table foo;
^
postgres=# drop table foo;
DROP TABLE
postgres=#

This is on 8.4.4. The semicolon is required.

On Tue, Jun 28, 2011 at 3:53 PM, Rich Shepard <rshepard@appl-ecosys.com>wrote:

On Tue, 28 Jun 2011, Rick Genter wrote:

Silly question, but did you try it with a semicolon after the drop table?

Rick,

See my answer to Andy: that's incorrect syntax and psql complains.

I've noticed that if you are in the middle of a statement and issue a \

command, psql ignores the SQL you've typed in and just does the \ command.

But there is no continuation command just 'drop table <tablename>'.

Thanks,

Rich

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/**mailpref/pgsql-general&lt;http://www.postgresql.org/mailpref/pgsql-general&gt;

--
Rick Genter
rick.genter@gmail.com

#7John R Pierce
pierce@hogranch.com
In reply to: Rick Genter (#6)
Re: DROP TABLE Appears to Fail

postgres=# drop table foo
postgres-# \d

specifically note the prompt. the -# means you're in the middle of a
command. =# means its ready for a new command.

as another example...

pierce=# create table foo (id integer);
CREATE TABLE
pierce=# drop
pierce-# table
pierce-# foo
pierce-# ;
DROP TABLE
pierce=#

--
john r pierce N 37, W 122
santa cruz ca mid-left coast

#8Rich Shepard
rshepard@appl-ecosys.com
In reply to: Rick Genter (#6)
Re: DROP TABLE Appears to Fail [SOLVED]

On Tue, 28 Jun 2011, Rick Genter wrote:

After issuing the \d you are still in the middle of your command. Witness
the following copy/paste of a terminal session:

Ah, so! I didn't see this.

Thank you very much,

Rich