{"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_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[133],"tags":[40],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-oracledb","tag-oracle-12c"],"acf":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_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}]}}