Thread: Re: DROP SEQUENCE ?

Re: DROP SEQUENCE ?

From
"Ian deSouza"
Date:
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
>
>
>



Re: DROP SEQUENCE ?

From
"Ian deSouza"
Date:
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
 
 
> 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
> >
> >
> >
>
>
>

Re[2]: DROP SEQUENCE ?

From
Mihail Marinov
Date:
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
>> I would have to do to follow the DROP TABLE w/ to remove the "sequence"
>> created by the SERIAL datatype?
>>
>> Thanks in advance, Ian
>>
>>
>>



Re[2]: DROP SEQUENCE ?

From
Mihail Marinov
Date:
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.



Re: Re: DROP SEQUENCE ?

From
"Oliver Elphick"
Date:
"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