Skip to main content
replaced http://dba.stackexchange.com/ with https://dba.stackexchange.com/
Source Link

Identity ColumnsIdentity Columns

This isn't exactly an answer yet, but what you want is GENERATED ALWAYS. And, it's on its way, maybe as soon as the next release of PostgreSQL, PostgreSQL 10

CREATE TABLE itest4 ( a int GENERATED ALWAYS AS IDENTITY, b text ); 

Syntax stolen verbatum from the emails about the patch.

Track the issue in the commitfest hereissue in the commitfest here.

From the SQL Spec,

If <identity column specification> is specified, then: i) An indication that the column is an identity column. ii) If ALWAYS is specified, then an indication that values are always generated. iii) If BY DEFAULT is specified, then an indication that values are generated by default. iv) The General Rules of Subclause 9.26, “Creation of a sequence generator”, are applied with SGO as OPTIONS and ICT as DATA TYPE; let the descriptor of the sequence generator SG be the SEQGENDESC returned from the application of those General Rules. 

Identity Columns

This isn't exactly an answer yet, but what you want is GENERATED ALWAYS. And, it's on its way, maybe as soon as the next release of PostgreSQL, PostgreSQL 10

CREATE TABLE itest4 ( a int GENERATED ALWAYS AS IDENTITY, b text ); 

Syntax stolen verbatum from the emails about the patch.

Track the issue in the commitfest here.

From the SQL Spec,

If <identity column specification> is specified, then: i) An indication that the column is an identity column. ii) If ALWAYS is specified, then an indication that values are always generated. iii) If BY DEFAULT is specified, then an indication that values are generated by default. iv) The General Rules of Subclause 9.26, “Creation of a sequence generator”, are applied with SGO as OPTIONS and ICT as DATA TYPE; let the descriptor of the sequence generator SG be the SEQGENDESC returned from the application of those General Rules. 

Identity Columns

This isn't exactly an answer yet, but what you want is GENERATED ALWAYS. And, it's on its way, maybe as soon as the next release of PostgreSQL, PostgreSQL 10

CREATE TABLE itest4 ( a int GENERATED ALWAYS AS IDENTITY, b text ); 

Syntax stolen verbatum from the emails about the patch.

Track the issue in the commitfest here.

From the SQL Spec,

If <identity column specification> is specified, then: i) An indication that the column is an identity column. ii) If ALWAYS is specified, then an indication that values are always generated. iii) If BY DEFAULT is specified, then an indication that values are generated by default. iv) The General Rules of Subclause 9.26, “Creation of a sequence generator”, are applied with SGO as OPTIONS and ICT as DATA TYPE; let the descriptor of the sequence generator SG be the SEQGENDESC returned from the application of those General Rules. 
added 593 characters in body
Source Link
Evan Carroll
  • 65.8k
  • 50
  • 263
  • 513

Identity Columns

This isn't exactly an answer yet, but what you want is GENERATED ALWAYS. And, it's on its way, maybe as soon as the next release of PostgreSQL, PostgreSQL 10

CREATE TABLE itest4 ( a int GENERATED ALWAYS AS IDENTITY, b text ); 

Syntax stolen verbatum from the emails about the patch.

Track the issue in the commitfest here.

From the SQL Spec,

If <identity column specification> is specified, then: i) An indication that the column is an identity column. ii) If ALWAYS is specified, then an indication that values are always generated. iii) If BY DEFAULT is specified, then an indication that values are generated by default. iv) The General Rules of Subclause 9.26, “Creation of a sequence generator”, are applied with SGO as OPTIONS and ICT as DATA TYPE; let the descriptor of the sequence generator SG be the SEQGENDESC returned from the application of those General Rules. 

Identity Columns

This isn't exactly an answer yet, but what you want is GENERATED ALWAYS. And, it's on its way, maybe as soon as the next release of PostgreSQL, PostgreSQL 10

CREATE TABLE itest4 ( a int GENERATED ALWAYS AS IDENTITY, b text ); 

Syntax stolen verbatum from the emails about the patch.

Track the issue in the commitfest here.

Identity Columns

This isn't exactly an answer yet, but what you want is GENERATED ALWAYS. And, it's on its way, maybe as soon as the next release of PostgreSQL, PostgreSQL 10

CREATE TABLE itest4 ( a int GENERATED ALWAYS AS IDENTITY, b text ); 

Syntax stolen verbatum from the emails about the patch.

Track the issue in the commitfest here.

From the SQL Spec,

If <identity column specification> is specified, then: i) An indication that the column is an identity column. ii) If ALWAYS is specified, then an indication that values are always generated. iii) If BY DEFAULT is specified, then an indication that values are generated by default. iv) The General Rules of Subclause 9.26, “Creation of a sequence generator”, are applied with SGO as OPTIONS and ICT as DATA TYPE; let the descriptor of the sequence generator SG be the SEQGENDESC returned from the application of those General Rules. 
Source Link
Evan Carroll
  • 65.8k
  • 50
  • 263
  • 513

Identity Columns

This isn't exactly an answer yet, but what you want is GENERATED ALWAYS. And, it's on its way, maybe as soon as the next release of PostgreSQL, PostgreSQL 10

CREATE TABLE itest4 ( a int GENERATED ALWAYS AS IDENTITY, b text ); 

Syntax stolen verbatum from the emails about the patch.

Track the issue in the commitfest here.