Re: Update to equivalent SQL in 8.1.4. Serial Types

Peter Eisentraut <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.documentation
Organization 2ndQuadrant
Message-ID <[email protected]>
On 2019-02-20 13:47, PG Doc comments form wrote:
> CREATE TABLE tablename (
>     colname SERIAL
> );
> 
> is equivalent to
> 
> CREATE SEQUENCE tablename_colname_seq;
> CREATE TABLE tablename (
>     colname integer NOT NULL DEFAULT nextval('tablename_colname_seq')
> );
> ALTER SEQUENCE tablename_colname_seq OWNED BY tablename.colname;
> 
> Since Postgres 10, the datatype of the automatically-created sequence
> matches the datatype of the serial column. But the default type for
> CREATE SEQUENCE remains as bigint. So the second block should start with
> the line
> 
> CREATE SEQUENCE tablename_colname_seq AS INTEGER;

fixed

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.