DROP SEQUENCE ?

Started by Ian deSouzaover 25 years ago7 messagesgeneral
Jump to latest
#1Ian deSouza
iandesouza@earthlink.net

Anybody know the syntax of the DROP SEQUENCE sql statement for PostgreSQL?

Once I create a table with an attribute of type SERIAL, and drop the table,
I cannot recreate the table since the sequence already exists (and DROP
TABLE tableName does not remove the sequence entry). Does anybody know what
I would have to do to follow the DROP TABLE w/ to remove the "sequence"
created by the SERIAL datatype?

Thanks in advance, Ian

#2Ian deSouza
iandesouza@earthlink.net
In reply to: Ian deSouza (#1)
Re: DROP SEQUENCE ?

The PostgreSQL doc referencing this situation is at
http://www.postgresql.org/devel-corner/docs/user/datatype.htm#AEN1181
but it doesn't explain what the syntax is nor does it give an example.
So if Employee has an attribute called ID that is of type SERIAL, and we do
a
"DROP TABLE EMPLOYEE"
what kind of call should we issue to drop the sequence?
DROP SEQUENCE ...??

"Ian deSouza" <iandesouza@earthlink.net> wrote in message
news:3Qv56.2577$Ps.115717@newsread2.prod.itd.earthlink.net...

Anybody know the syntax of the DROP SEQUENCE sql statement for PostgreSQL?

Once I create a table with an attribute of type SERIAL, and drop the

table,

I cannot recreate the table since the sequence already exists (and DROP
TABLE tableName does not remove the sequence entry). Does anybody know

what

Show quoted text

I would have to do to follow the DROP TABLE w/ to remove the "sequence"
created by the SERIAL datatype?

Thanks in advance, Ian

#3Ian deSouza
iandesouza@earthlink.net
In reply to: Ian deSouza (#1)
Re: DROP SEQUENCE ?

Figure it out:

metamousetrap=> create table my_table (first serial, second varchar);
NOTICE: CREATE TABLE will create implicit sequence 'my_table_first_seq' for SERIAL column 'my_table.first'
NOTICE: CREATE TABLE/UNIQUE will create implicit index 'my_table_first_key' for table 'my_table'
CREATE
metamousetrap=> drop table my_table;
DROP
metamousetrap=> drop sequence my_table_first_seq;
DROP

Anyone know how to list what sequences already exist?

Thanks, Ian

"Ian deSouza" <iandesouza@earthlink.net> wrote in message news:%4I56.7010$Ps.320023@newsread2.prod.itd.earthlink.net...

Show quoted text

The PostgreSQL doc referencing this situation is at
http://www.postgresql.org/devel-corner/docs/user/datatype.htm#AEN1181
but it doesn't explain what the syntax is nor does it give an example.
So if Employee has an attribute called ID that is of type SERIAL, and we do
a
"DROP TABLE EMPLOYEE"
what kind of call should we issue to drop the sequence?
DROP SEQUENCE ...??

"Ian deSouza" <iandesouza@earthlink.net> wrote in message
news:3Qv56.2577$Ps.115717@newsread2.prod.itd.earthlink.net...

Anybody know the syntax of the DROP SEQUENCE sql statement for PostgreSQL?

Once I create a table with an attribute of type SERIAL, and drop the

table,

I cannot recreate the table since the sequence already exists (and DROP
TABLE tableName does not remove the sequence entry). Does anybody know

what

I would have to do to follow the DROP TABLE w/ to remove the "sequence"
created by the SERIAL datatype?

Thanks in advance, Ian

#4Mihail Marinov
liahim@bcci.bg
In reply to: Ian deSouza (#2)
Re[2]: DROP SEQUENCE ?

DROP SEQUENCE EMPLOYEE_ID_seq;
And it is in the docs..

Id> The PostgreSQL doc referencing this situation is at
Id> http://www.postgresql.org/devel-corner/docs/user/datatype.htm#AEN1181
Id> but it doesn't explain what the syntax is nor does it give an example.
Id> So if Employee has an attribute called ID that is of type SERIAL, and we do
Id> a
Id> "DROP TABLE EMPLOYEE"
Id> what kind of call should we issue to drop the sequence?
Id> DROP SEQUENCE ...??

Id> "Ian deSouza" <iandesouza@earthlink.net> wrote in message
Id> news:3Qv56.2577$Ps.115717@newsread2.prod.itd.earthlink.net...

Anybody know the syntax of the DROP SEQUENCE sql statement for PostgreSQL?

Once I create a table with an attribute of type SERIAL, and drop the

Id> table,

I cannot recreate the table since the sequence already exists (and DROP
TABLE tableName does not remove the sequence entry). Does anybody know

Id> what

Show quoted text

I would have to do to follow the DROP TABLE w/ to remove the "sequence"
created by the SERIAL datatype?

Thanks in advance, Ian

#5Mihail Marinov
liahim@bcci.bg
In reply to: Ian deSouza (#3)
Re[2]: DROP SEQUENCE ?

Id> Figure it out:

metamousetrap=>> create table my_table (first serial, second varchar);
Id> NOTICE: CREATE TABLE will create implicit sequence 'my_table_first_seq' for SERIAL column 'my_table.first'
Id> NOTICE: CREATE TABLE/UNIQUE will create implicit index 'my_table_first_key' for table 'my_table'
Id> CREATE
metamousetrap=>> drop table my_table;
Id> DROP
metamousetrap=>> drop sequence my_table_first_seq;
Id> DROP

Id> Anyone know how to list what sequences already exist?

Id> Thanks, Ian

\ds would do.

#6Oliver Elphick
olly@lfix.co.uk
In reply to: Ian deSouza (#3)
Re: Re: DROP SEQUENCE ?

"Ian deSouza" wrote:

Anyone know how to list what sequences already exist?

In psql: \ds

--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"Blessed are the pure in heart, for they shall see
God." Matthew 5:8

#7imago
imago@imago3d.com
In reply to: Ian deSouza (#1)
Re: DROP SEQUENCE ?

Are you using the right name for the sequence> I am very new to sql
so I might be off base here but the name of the sequence is:

<tablename>_<serialdatatypename>_id_seq

sql snippet

DROP TABLE members;
DROP
DROP SEQUENCE members_member_id_seq;
DROP

CREATE TABLE members (
member_id serial,
member_type VARCHAR(10),
username VARCHAR(20),
password VARCHAR(20),
prefix VARCHAR(10),
name_first VARCHAR(20),
name_last VARCHAR(20),
name_suffix VARCHAR(10),
address_street1 VAR CHAR(25),
address_street2 VAR CHAR(25),
address_city VARCHAR(20),
address_state VARCHAR(2),
address_zip VARCHAR(10),
phone VARCHAR(13),
email VARCHAR(30),
timedate_creation TIMESTAMP,
timedate_mod TIMESTAMP,
rating INTEGER,
preferences VARCHAR(100),
account_bal NUMERIC(16,2)
);
NOTICE: CREATE TABLE will create implicit sequence
'members_member_id_seq' for SERIAL column 'members.member_id'
NOTICE: CREATE TABLE/UNIQUE will create implicit index
'members_member_id_key' for table 'members'
CREATE

imago

----- Original Message -----
From: "Ian deSouza" <iandesouza@earthlink.net>
To: <>
Sent: Friday, January 05, 2001 9:57 PM
Subject: [GENERAL] DROP SEQUENCE ?

Anybody know the syntax of the DROP SEQUENCE sql statement for

PostgreSQL?

Once I create a table with an attribute of type SERIAL, and drop

the table,

I cannot recreate the table since the sequence already exists (and

DROP

TABLE tableName does not remove the sequence entry). Does anybody

know what

I would have to do to follow the DROP TABLE w/ to remove the

"sequence"

Show quoted text

created by the SERIAL datatype?

Thanks in advance, Ian