sequence creation

Started by Bruce Momjianover 27 years ago7 messages
#1Bruce Momjian
maillist@candle.pha.pa.us

Right now, we allow PRIMARY to auto-create an index.

Can we have something to auto-create sequences, instead of the more
complicated CREATE SEQUENCE process.

Perhaps use the data type SERIAL to autocreate a sequence. Should make
life easier for novices. We are getting too many sequence questions.

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)
#2Jackson, DeJuan
djackson@cpsgroup.com
In reply to: Bruce Momjian (#1)
RE: [HACKERS] sequence creation

Right now, we allow PRIMARY to auto-create an index.

Can we have something to auto-create sequences, instead of the more
complicated CREATE SEQUENCE process.

Perhaps use the data type SERIAL to autocreate a sequence. Should
make
life easier for novices. We are getting too many sequence questions.

I'm all for it.

-DEJ

#3Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Jackson, DeJuan (#2)
Re: [HACKERS] sequence creation

Right now, we allow PRIMARY to auto-create an index.
Can we have something to auto-create sequences, instead of the more
complicated CREATE SEQUENCE process.
Perhaps use the data type SERIAL to autocreate a sequence. Should
make life easier for novices. We are getting too many sequence
questions.

That would be possible. I'd be happier doing it for v6.5, since I'm
hoping to work on docs in the meantime. Of course, maybe it would be
easy :)

What should the syntax be exactly?

CREATE TABLE t (s SERIAL);

or

CREATE TABLE t (i INT DEFAULT SERIAL);

or ??

Are there alternate syntaxes from other DBs which should be considered?

Can't be that hard. I like the first one myself, and it matches
Informix.

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)
#4Thomas G. Lockhart
lockhart@alumni.caltech.edu
In reply to: Bruce Momjian (#1)
Re: [HACKERS] sequence creation

Right now, we allow PRIMARY to auto-create an index.
Can we have something to auto-create sequences, instead of the more
complicated CREATE SEQUENCE process.
Perhaps use the data type SERIAL to autocreate a sequence. Should
make life easier for novices. We are getting too many sequence
questions.

That would be possible. I'd be happier doing it for v6.5, since I'm
hoping to work on docs in the meantime. Of course, maybe it would be
easy :)

What should the syntax be exactly?

CREATE TABLE t (s SERIAL);

or

CREATE TABLE t (i INT DEFAULT SERIAL);

or ??

Are there alternate syntaxes from other DBs which should be considered?

- Tom

#5Noname
darcy@druid.net
In reply to: Thomas G. Lockhart (#4)
Re: [HACKERS] sequence creation\

Thus spake Thomas G. Lockhart

Perhaps use the data type SERIAL to autocreate a sequence. Should
make life easier for novices. We are getting too many sequence
questions.

That would be possible. I'd be happier doing it for v6.5, since I'm
hoping to work on docs in the meantime. Of course, maybe it would be
easy :)

What should the syntax be exactly?

CREATE TABLE t (s SERIAL);

or

CREATE TABLE t (i INT DEFAULT SERIAL);

I think the first one is simpler and, as far as I know, is more common
in existing practice.

Are there alternate syntaxes from other DBs which should be considered?

The standard doesn't specify a serial type. One question would be,
what is the behaviour? Should the field always be set to the next
number on insert or should we be able to override it? I prefer the
former but I can see that it would be a problem on dump and reload.
How do other DBs handle this?

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 424 2871     (DoD#0082)    (eNTP)   |  what's for dinner.
#6Andreas Zeugswetter
andreas.zeugswetter@telecom.at
In reply to: Thomas G. Lockhart (#4)
AW: [HACKERS] sequence creation

Right now, we allow PRIMARY to auto-create an index.
Can we have something to auto-create sequences, instead of the more
complicated CREATE SEQUENCE process.
Perhaps use the data type SERIAL to autocreate a sequence. Should
make life easier for novices. We are getting too many sequence
questions.

That would be possible. I'd be happier doing it for v6.5, since I'm
hoping to work on docs in the meantime. Of course, maybe it would be
easy :)

What should the syntax be exactly?

CREATE TABLE t (s SERIAL);

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

exactly this. :-) (like in Informix)

Informix also allows to specify a starting value like:
create table t (s serial(1000));
defaulting to 1 but I think this additional syntax is rather misleading

Andreas

#7Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Andreas Zeugswetter (#6)
Re: AW: [HACKERS] sequence creation

Right now, we allow PRIMARY to auto-create an index.
Can we have something to auto-create sequences, instead of the more
complicated CREATE SEQUENCE process.
Perhaps use the data type SERIAL to autocreate a sequence. Should
make life easier for novices. We are getting too many sequence
questions.

That would be possible. I'd be happier doing it for v6.5, since I'm
hoping to work on docs in the meantime. Of course, maybe it would be
easy :)

What should the syntax be exactly?

CREATE TABLE t (s SERIAL);

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

exactly this. :-) (like in Informix)

Informix also allows to specify a starting value like:
create table t (s serial(1000));
defaulting to 1 but I think this additional syntax is rather misleading

Thanks to Thomas, this will be in 6.4.

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)