Question:
How do I produce the syntax for Identity in erwin DM for PostgreSQL?
Solution:
In PostgreSQL, Identity clause has been introduced with v 10. As of erwin DM v. 2019 R1, only version 9.6 of PostgreSQL is supported which does not have that property. However, there is a way to accomplish it which is to create a Sequence and attach a Default to the Column using that Sequence. Here is how you can use the equivalent of Identity syntax for PostgreSQL 9.6.
1. Create a Sequence, e.g. with a name TEST_SEQ1
2. Create a Table with a few Columns
3. Create a Default Rule (any name) with a value as follows:
Nextval('TEST_SEQ1') -- please note that the name should be same as the Sequence name
4. For the Column where a Sequence is needed, make the datatype as Serial, Integer, or Smallint - it has to be numeric.
5. Associate the Default as created in # 3 above to that Column.
The syntax generated will then have the Default as Nextval using the Sequence name. This is how it works in the database for 9.6.
Please also see http://www.postgresqltutorial.com/postgresql-identity-column/
Comments
0 comments
Please sign in to leave a comment.