{"id":102,"date":"2013-07-03T07:35:13","date_gmt":"2013-07-03T12:35:13","guid":{"rendered":"https:\/\/bijoos.com\/oraclenotes\/?p=102"},"modified":"2026-02-07T15:35:10","modified_gmt":"2026-02-07T21:35:10","slug":"oracledb12c-new-feature-identity-column","status":"publish","type":"post","link":"https:\/\/bijoos.com\/oraclenotes\/2013\/102\/","title":{"rendered":"OracleDB12c New Feature: Identity Column"},"content":{"rendered":"<p>Let&#8217;s talk about a &#8220;developer&#8221; feature today. If you have a need to generate a column value [mostly primary key] based on a sequence, in pre-12c Oracle database we have to create a number data type column in the table, and use a sequence that is separately created. There is no restriction that the sequence can be used only to populate one table or column.<\/p>\n<p>To comply with ANSI SQL [extension] Oracle 12c now includes the &#8220;INDENTITY&#8221; column. While defining the table [CREATE TABLE] or modifying the table [ALTER TABLE] you can now define the IDENTITY column with a &#8220;sequence generator&#8221; definition.<\/p>\n<p>According to <strong><a title=\"Read more about IDENTITY column\" href=\"http:\/\/docs.oracle.com\/cd\/E16655_01\/server.121\/e17209\/statements_7002.htm#CJAHJHJC\" target=\"_blank\">Oracle documentation<\/a><\/strong>, the syntax for this new option in CREATE TABLE is<\/p>\n<pre class=\"lang:default highlight:0 decode:true\" title=\"CREATE TABLE or ALTER TABLE option for IDENTITY\">GENERATED\n[ ALWAYS | BY DEFAULT [ ON NULL ] ]\nAS IDENTITY [ ( identity_options ) ]<\/pre>\n<p>GENERATED keyword tells Oracle that this column value is generated.<\/p>\n<p>ALWAYS is the default and specifies that the column value is never assigned and during INSERT\/UDPATE statements, this column will always be evaluated to NULL &#8211; value will be populated by Oracle based on the &#8220;identity_options&#8221;.<\/p>\n<p>BY DEFAULT specifies that the column value is generated by Oracle (similar to ALWAYS), but you can explicitly assign values to the column using INSERT\/UPDATE statements. If you specify ON NULL with BY DEFAULT, generated value is assigned to the column only when the column value is evaluated to NULL during INSERT\/UPDATE.<\/p>\n<p>&#8220;identity_options&#8221; is basically the syntax for sequence generator &#8211; same as the CREATE SEQUENCE options.<\/p>\n<p>There are some restrictions, please read the Oracle documentation link above. Notable one is that you can have only one IDENTITY column per table. IDENTITY column has a NOT NULL constraint automatically created.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s talk about a &#8220;developer&#8221; feature today. If you have a need to generate a column value [mostly primary key] based on a sequence, in pre-12c Oracle database we have to create a number data type column in the table, and use a sequence that is separately created. There is no restriction that the sequence &#8230; <a title=\"OracleDB12c New Feature: Identity Column\" class=\"read-more\" href=\"https:\/\/bijoos.com\/oraclenotes\/2013\/102\/\" aria-label=\"Read more about OracleDB12c New Feature: Identity Column\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[133],"tags":[40],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-oracledb","tag-oracle-12c"],"acf":[],"jetpack-related-posts":[{"id":128,"url":"https:\/\/bijoos.com\/oraclenotes\/2013\/128\/","url_meta":{"origin":102,"position":0},"title":"OracleDB12c New Feature: Use of Sequence Value in Column DEFAULT","author":"Biju","date":"July 4, 2013","format":false,"excerpt":"Happy 4th of July! In the 12c new feature a day series, I discussed the \"Identity Column\" feature yesterday. Extension to that feature is now you can use sequence \u00a0pseudo-column NETXTVAL or CURRVAL as DEFAULT value for a column in table definition. In the prior releases to be able to\u2026","rel":"","context":"In &quot;Oracle Database&quot;","block_context":{"text":"Oracle Database","link":"https:\/\/bijoos.com\/oraclenotes\/category\/oracledb\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":393,"url":"https:\/\/bijoos.com\/oraclenotes\/2014\/393\/","url_meta":{"origin":102,"position":1},"title":"OracleNotes TidBits &#8211; May 2014","author":"Biju","date":"May 31, 2014","format":false,"excerpt":"According to the dictionary, meaning of \"tidbit\" is \"a small and particularly interesting item of gossip or information\"... hope you find the \"Oracle TidBits\" published at https:\/\/www.facebook.com\/oraclenotes\u00a0interesting... Here is a compilation of the tidbits published in May 2014. You will also see these tidbits, one tidbit at a time, for\u2026","rel":"","context":"In &quot;TidBits &amp; Quick Tips&quot;","block_context":{"text":"TidBits &amp; Quick Tips","link":"https:\/\/bijoos.com\/oraclenotes\/category\/tidbits\/"},"img":{"alt_text":"Oracle TidBit","src":"https:\/\/i0.wp.com\/bijoos.com\/oraclenotes\/wp-content\/uploads\/2014\/05\/TidBit-300x123.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":153,"url":"https:\/\/bijoos.com\/oraclenotes\/2013\/153\/","url_meta":{"origin":102,"position":2},"title":"OracleDB12c New Feature: Last Login Time of User","author":"Biju","date":"July 9, 2013","format":false,"excerpt":"The SYS.USER$ table in Oracle Database 12c includes a column to store the last login time of the user. In the previous releases, to be able to know the last login time of the user, we had to enable \"AUDIT SESSION\" and then query the AUD$ table. As part of\u2026","rel":"","context":"In &quot;Oracle Database&quot;","block_context":{"text":"Oracle Database","link":"https:\/\/bijoos.com\/oraclenotes\/category\/oracledb\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":183,"url":"https:\/\/bijoos.com\/oraclenotes\/2013\/183\/","url_meta":{"origin":102,"position":3},"title":"OracleDB12c New Feature: Exporting View Data","author":"Biju","date":"July 12, 2013","format":false,"excerpt":"Oracle Database 12c datapump export expdp has an option to export the views as tables. Expdp exports the view definition as a table and its data. This is an extremely useful feature to export subset of data. At import time, datapump creates the table with column name and data type\u2026","rel":"","context":"In &quot;Oracle Database&quot;","block_context":{"text":"Oracle Database","link":"https:\/\/bijoos.com\/oraclenotes\/category\/oracledb\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1619,"url":"https:\/\/bijoos.com\/oraclenotes\/2015\/1619\/","url_meta":{"origin":102,"position":4},"title":"Invisible Columns in Oracle Database 12c","author":"Biju","date":"October 14, 2015","format":false,"excerpt":"In May 2014, the following #oratidbit relating to invisible columns were tweeted. In #DB12c, you can make a column in table as INVISIBLE. When you make it invisible, the COL# column in COL$ dictionary is updated to 0, thus is not included in the \"SELECT *\" or \"INSERT INTO VALUES\",\u2026","rel":"","context":"In &quot;Oracle Database&quot;","block_context":{"text":"Oracle Database","link":"https:\/\/bijoos.com\/oraclenotes\/category\/oracledb\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":495,"url":"https:\/\/bijoos.com\/oraclenotes\/2014\/495\/","url_meta":{"origin":102,"position":5},"title":"Oracle TidBits &#8211; July 2014","author":"Biju","date":"August 1, 2014","format":false,"excerpt":"\u201cOracle *daily* TidBits\u201d published at\u00a0https:\/\/www.facebook.com\/oraclenotes\u00a0on all weekdays\u00a0in July 2014. You will also see these tidbits, one tidbit at a time, for each page refresh on the right side of this blog as well\u2026 Hope you find these helpful to learn something new or to remind you of its existence and\u2026","rel":"","context":"In &quot;TidBits &amp; Quick Tips&quot;","block_context":{"text":"TidBits &amp; Quick Tips","link":"https:\/\/bijoos.com\/oraclenotes\/category\/tidbits\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/comments?post=102"}],"version-history":[{"count":1,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":3035,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/posts\/102\/revisions\/3035"}],"wp:attachment":[{"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/media?parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/categories?post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/tags?post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}