<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Sequences</title>
    <link>/en/admin/working-with-native-tables/sequences/</link>
    <description>Recent content in Sequences on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/admin/working-with-native-tables/sequences/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Admin: Sequence types compared</title>
      <link>/en/admin/working-with-native-tables/sequences/sequence-types-compared/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/working-with-native-tables/sequences/sequence-types-compared/</guid>
      <description>
        
        
        &lt;p&gt;The following table lists the differences between the two sequence types:

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;th &gt;
Supported Behavior&lt;/th&gt; 

&lt;th &gt;
Named Sequence&lt;/th&gt; 

&lt;th &gt;
IDENTITY&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Default cache value 250K&lt;/td&gt; 

&lt;td &gt;
•&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Set initial cache&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
•&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Define start value&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
•&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Specify increment unit&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
•&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Exists as an independent object&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Exists only as part of table&lt;/td&gt; 

&lt;td &gt;
&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Create as column constraint&lt;/td&gt; 

&lt;td &gt;
&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Requires name&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Use in expressions&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Unique across tables&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Change parameters&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Move to different schema&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Set to increment or decrement&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Grant privileges to object&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Specify minimum value&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Specify maximum value&lt;/td&gt; 

&lt;td &gt;


•&lt;/td&gt; 

&lt;td &gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Named sequences</title>
      <link>/en/admin/working-with-native-tables/sequences/named-sequences/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/working-with-native-tables/sequences/named-sequences/</guid>
      <description>
        
        
        &lt;p&gt;Named sequences are sequences that are defined by &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-sequence/#&#34;&gt;CREATE SEQUENCE&lt;/a&gt;. Unlike &lt;a href=&#34;../../../../en/admin/working-with-native-tables/sequences/identity-sequences/&#34;&gt;IDENTITY sequences&lt;/a&gt;, which are defined in a table&#39;s DDL, you create a named sequence as an independent object, and then set it as the default value of a table column.&lt;/p&gt;
&lt;p&gt;Named sequences are used most often when an application requires a unique identifier in a table or an expression. After a named sequence returns a value, it never returns the same value again in the same session.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: IDENTITY sequences</title>
      <link>/en/admin/working-with-native-tables/sequences/identity-sequences/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/working-with-native-tables/sequences/identity-sequences/</guid>
      <description>
        
        
        &lt;p&gt;IDENTITY (synonymous with AUTO_INCREMENT) columns are defined with a sequence that automatically increments column values as new rows are added. You define an IDENTITY column in a table as follows:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CREATE TABLE &lt;span class=&#34;code-variable&#34;&gt;table-name&lt;/span&gt;...
  (&lt;span class=&#34;code-variable&#34;&gt;column-name&lt;/span&gt; {IDENTITY | AUTO_INCREMENT}
      ( [ &lt;span class=&#34;code-variable&#34;&gt;cache-size&lt;/span&gt; | &lt;span class=&#34;code-variable&#34;&gt;start&lt;/span&gt;, &lt;span class=&#34;code-variable&#34;&gt;increment&lt;/span&gt; [, &lt;span class=&#34;code-variable&#34;&gt;cache-size&lt;/span&gt; ] ] )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;settings&#34;&gt;Settings&lt;/h2&gt;

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;td &gt;
&lt;em&gt;&lt;code&gt;start&lt;/code&gt;&lt;/em&gt;&lt;/td&gt; 

&lt;td &gt;




&lt;p&gt;First value to set for this column.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Default:&lt;/strong&gt; 1&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;em&gt;&lt;code&gt;increment&lt;/code&gt;&lt;/em&gt;&lt;/td&gt; 

&lt;td &gt;











&lt;p&gt;Positive or negative integer that specifies how much to increment or decrement the sequence on each new row insertion from the previous row value, by default set to 1. To decrement sequence values, specify a negative value.&lt;/p&gt;
&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;
&lt;p&gt;The actual amount by which column values are incremented or decremented might be larger than the &lt;em&gt;&lt;code&gt;increment&lt;/code&gt;&lt;/em&gt; setting, unless &lt;a href=&#34;../../../../en/admin/working-with-native-tables/sequences/sequence-caching/&#34;&gt;sequence caching&lt;/a&gt; is disabled.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Default:&lt;/strong&gt; 1&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;em&gt;&lt;code&gt;cache-size&lt;/code&gt;&lt;/em&gt;&lt;/td&gt; 

&lt;td &gt;




&lt;p&gt;How many unique numbers each node caches per session. A value of 0 or 1 disables sequence caching. For details, see &lt;a href=&#34;../../../../en/admin/working-with-native-tables/sequences/sequence-caching/#&#34;&gt;Sequence caching&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Default:&lt;/strong&gt; 250,000&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;&lt;a name=&#34;Managing&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;managing-settings&#34;&gt;Managing settings&lt;/h2&gt;
&lt;p&gt;Like &lt;a href=&#34;../../../../en/admin/working-with-native-tables/sequences/named-sequences/&#34;&gt;named sequences&lt;/a&gt;, you can manage an IDENTITY column with &lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-sequence/#&#34;&gt;ALTER SEQUENCE&lt;/a&gt;—for example, reset its start integer. Two exceptions apply: because the sequence is defined as part of a table column, you cannot change the sequence name or schema. You can query the &lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/sequences/#&#34;&gt;SEQUENCES&lt;/a&gt; system table for the name of an IDENTITY column&#39;s sequence. This name is automatically created when you define the table, and conforms to the following convention:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&lt;span class=&#34;code-variable&#34;&gt;table-name&lt;/span&gt;_&lt;span class=&#34;code-variable&#34;&gt;col-name&lt;/span&gt;_seq
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;For example, you can change the maximum value of an IDENTITY column that is defined in the &lt;code&gt;testAutoId&lt;/code&gt; table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM sequences WHERE identity_table_name  = &amp;#39;testAutoId&amp;#39;;
-[ RECORD 1 ]-------+-------------------------
sequence_schema     | public
sequence_name       | testAutoId_autoIdCol_seq
owner_name          | dbadmin
identity_table_name | testAutoId
session_cache_count | 250000
allow_cycle         | f
output_ordered      | f
increment_by        | 1
minimum             | 1
maximum             | 1000
current_value       | 1
sequence_schema_id  | 45035996273704980
sequence_id         | 45035996274278950
owner_id            | 45035996273704962
identity_table_id   | 45035996274278948

=&amp;gt; ALTER SEQUENCE testAutoId_autoIdCol_seq maxvalue 10000;
ALTER SEQUENCE
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This change, like other changes to a sequence, take effect only when you start a new database session. One exception applies: changes to the sequence owner take effect immediately.&lt;/p&gt;
&lt;p&gt;You can obtain the last value generated for an IDENTITY column by calling &lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/table-functions/last-insert-id/#&#34;&gt;LAST_INSERT_ID&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;restrictions&#34;&gt;Restrictions&lt;/h2&gt;
&lt;p&gt;The following restrictions apply to IDENTITY columns:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A table can contain only one IDENTITY column.&lt;/li&gt;
&lt;li&gt;IDENTITY column values automatically increment before the current transaction is committed; rolling back the transaction does not revert the change.&lt;/li&gt;
&lt;li&gt;You cannot change the value of an IDENTITY column.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following example shows how to use the IDENTITY column-constraint to create a table with an ID column. The ID column has an initial value of 1. It is incremented by 1 every time a row is inserted.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create table &lt;code&gt;Premium_Customer&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE Premium_Customer(
     ID IDENTITY(1,1),
     lname VARCHAR(25),
     fname VARCHAR(25),
     store_membership_card INTEGER
);
=&amp;gt; INSERT INTO Premium_Customer (lname, fname, store_membership_card )
     VALUES (&amp;#39;Gupta&amp;#39;, &amp;#39;Saleem&amp;#39;, 475987);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The IDENTITY column has a seed of 1, which specifies the value for the first row loaded into the table, and an increment of 1, which specifies the value that is added to the IDENTITY value of the previous row.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Confirm the row you added and see the ID value:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM Premium_Customer;
 ID | lname | fname  | store_membership_card
----+-------+--------+-----------------------
  1 | Gupta | Saleem |                475987
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add another row:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; INSERT INTO Premium_Customer (lname, fname, store_membership_card)
   VALUES (&amp;#39;Lee&amp;#39;, &amp;#39;Chen&amp;#39;, 598742);
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Call the function &lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/table-functions/last-insert-id/#&#34;&gt;LAST_INSERT_ID&lt;/a&gt;. The function returns value 2 because you previously inserted a new customer (Chen Lee), and this value is incremented each time a row is inserted:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT LAST_INSERT_ID();
 last_insert_id
----------------
               2
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;View all the ID values in the &lt;code&gt;Premium_Customer&lt;/code&gt; table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM Premium_Customer;
 ID | lname | fname  | store_membership_card
----+-------+--------+-----------------------
  1 | Gupta | Saleem |                475987
  2 | Lee   | Chen   |                598742
(2 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The next three examples illustrate the three valid ways to use IDENTITY arguments.&lt;/p&gt;
&lt;p&gt;The first example uses a cache of 100, and the defaults for start value (1) and increment value (1):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE t1(x IDENTITY(100), y INT);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The next example specifies the start and increment values as 1, and defaults to a cache value of 250,000:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE t2(y IDENTITY(1,1), x INT);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The third example specifies start and increment values of 1, and a cache value of 100:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE t3(z IDENTITY(1,1,100), zx INT);
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Admin: Sequence caching</title>
      <link>/en/admin/working-with-native-tables/sequences/sequence-caching/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/working-with-native-tables/sequences/sequence-caching/</guid>
      <description>
        
        
        &lt;p&gt;Caching is similar for all sequence types: &lt;a href=&#34;../../../../en/admin/working-with-native-tables/sequences/named-sequences/&#34;&gt;named sequences&lt;/a&gt; and &lt;a href=&#34;../../../../en/admin/working-with-native-tables/sequences/identity-sequences/&#34;&gt;IDENTITY column&lt;/a&gt; sequences. To allocate cache among the nodes in a cluster for a given sequence, the database uses the following process.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;By default, when a session begins, the cluster initiator node requests cache for itself and other nodes in the cluster.&lt;/li&gt;
&lt;li&gt;The initiator node distributes cache to other nodes when it distributes the execution plan.&lt;/li&gt;
&lt;li&gt;Because the initiator node requests caching for all nodes, only the initiator locks the global catalog for the cache request.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This approach is optimal for handling large INSERT-SELECT and COPY operations. The following figure shows how the initiator request and distributes cache for a named sequence in a three-node cluster, where caching for that sequence is set to 250 K:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../../../../images/admin-cluster-sequence-caching/initial-cache-sequence-request4.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Nodes run out of cache at different times. While executing the same query, nodes individually request additional cache as needed.&lt;/p&gt;
&lt;p&gt;For new queries in the same session, the initiator might have an empty cache if it used all of its cache to execute the previous query execution. In this case, the initiator requests cache for all nodes.&lt;/p&gt;
&lt;h2 id=&#34;configuring-sequence-caching&#34;&gt;Configuring sequence caching&lt;/h2&gt;
&lt;p&gt;You can change how nodes obtain sequence caches by setting the configuration parameter &lt;a href=&#34;../../../../en/sql-reference/config-parameters/general-parameters/#ClusterSequenceCacheMode&#34;&gt;ClusterSequenceCacheMode&lt;/a&gt; to 0 (disabled). When this parameter is set to 0, all nodes in the cluster request their own cache and catalog lock. However, for initial large INSERT-SELECT and COPY operations, when the cache is empty for all nodes, each node requests cache at the same time. These multiple requests result in simultaneous locks on the global catalog, which can adversely affect performance. For this reason, ClusterSequenceCacheMode should remain set to its default value of 1 (enabled).&lt;/p&gt;
&lt;p&gt;The following example compares how different settings of ClusterSequenceCacheMode affect how the database manages sequence caching. The example assumes a three-node cluster, 250 K caches for each node (the default), and sequence ID values that increment by 1.

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;th &gt;


Workflow step&lt;/th&gt; 

&lt;th &gt;
ClusterSequenceCacheMode = 1&lt;/th&gt; 

&lt;th &gt;
ClusterSequenceCacheMode = 0&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


1&lt;/td&gt; 

&lt;td &gt;




&lt;p&gt;Cache is empty for all nodes.&lt;/p&gt;
&lt;p&gt;Initiator node requests 250 K cache for each node.&lt;/p&gt;
&lt;/td&gt; 

&lt;td &gt;




&lt;p&gt;Cache is empty for all nodes.&lt;/p&gt;
&lt;p&gt;Each node, including initiator, requests its own 250 K cache.&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
2&lt;/td&gt; 

&lt;td  colspan=&#34;2&#34; &gt;










&lt;p&gt;Blocks of cache are distributed to each node as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Node 1: 0–250 K&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Node 2: 250 K + 1 to 500 K&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Node 3: 500 K + 1 to 750 K&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each node begins to use its cache as it processes sequence updates.&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
3&lt;/td&gt; 

&lt;td  colspan=&#34;2&#34; &gt;




&lt;p&gt;Initiator node and node 3 run out of cache.&lt;/p&gt;
&lt;p&gt;Node 2 only uses 250 K +1 to 400 K, 100 K of cache remains from 400 K +1 to 500 K.&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
4&lt;/td&gt; 

&lt;td &gt;












&lt;p&gt;Executing same statement:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;As each node uses up its cache, it requests a new cache allocation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If node 2 never uses its cache, the 100-K unused cache becomes a gap in sequence IDs.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Executing a new statement in same session, if initiator node cache is empty:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;It requests and distributes new cache blocks for all nodes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Nodes receive a new cache before the old cache is used, creating a gap in ID sequencing.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt; 

&lt;td &gt;






&lt;p&gt;Executing same or new statement:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;As each node uses up its cache, it requests a new cache allocation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If node 2 never uses its cache, the 100 K unused cache becomes a gap in sequence IDs.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;

      </description>
    </item>
    
  </channel>
</rss>
