<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Constraint enforcement</title>
    <link>/en/admin/constraints/constraint-enforcement/</link>
    <description>Recent content in Constraint enforcement on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/admin/constraints/constraint-enforcement/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Admin: Levels of constraint enforcement</title>
      <link>/en/admin/constraints/constraint-enforcement/levels-of-constraint-enforcement/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/constraints/constraint-enforcement/levels-of-constraint-enforcement/</guid>
      <description>
        
        
        &lt;p&gt;Constraints can be enforced at two levels:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#Constrai&#34;&gt;Database configuration parameters &lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#Table-Co&#34;&gt;Table constraints&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name=&#34;Constrai&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;constraint-enforcement-parameters&#34;&gt;Constraint enforcement parameters&lt;/h2&gt;
&lt;p&gt;OpenText™ Analytics Database supports three Boolean parameters to enforce constraints:

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



&lt;tr&gt; 

&lt;th &gt;
Enforcement parameter&lt;/th&gt; 

&lt;th &gt;
Default setting&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;EnableNewPrimaryKeysByDefault&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
0 (false/disabled)&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;EnableNewUniqueKeysByDefault&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
0 (false/disabled)&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
&lt;code&gt;EnableNewCheckConstraintsByDefault&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;
1 (true/enabled)&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a name=&#34;Table-Co&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;table-constraint-enforcement&#34;&gt;Table constraint enforcement&lt;/h2&gt;
&lt;p&gt;You set constraint enforcement on tables through 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-table/#&#34;&gt;CREATE TABLE&lt;/a&gt;&lt;/code&gt; and 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-table/#&#34;&gt;ALTER TABLE&lt;/a&gt;&lt;/code&gt;, by qualifying the constraints with the keywords &lt;code&gt;ENABLED&lt;/code&gt; or &lt;code&gt;DISABLED&lt;/code&gt;. The following &lt;code&gt;CREATE TABLE&lt;/code&gt; statement enables enforcement of a check constraint in its definition of column &lt;code&gt;order_qty&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE new_orders (
   cust_id int,
   order_date timestamp DEFAULT CURRENT_TIMESTAMP,
   product_id varchar(12),
   order_qty int CHECK(order_qty &amp;gt; 0) ENABLED,
   PRIMARY KEY(cust_id, order_date) ENABLED
);
CREATE TABLE
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;ALTER TABLE&lt;/code&gt; can enable enforcement on existing constraints. The following statement modifies table &lt;code&gt;customer_dimension&lt;/code&gt; by enabling enforcement on named constraint &lt;code&gt;C_UNIQUE&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; ALTER TABLE public.customer_dimension ALTER CONSTRAINT C_UNIQUE ENABLED;
ALTER TABLE
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;enforcement-level-precedence&#34;&gt;Enforcement level precedence&lt;/h2&gt;
&lt;p&gt;Table and column enforcement settings have precedence over enforcement parameter settings. If a table or column constraint omits &lt;code&gt;ENABLED&lt;/code&gt; or &lt;code&gt;DISABLED&lt;/code&gt;, the database uses the current settings of the pertinent configuration parameters.

&lt;div class=&#34;admonition important&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Important&lt;/h4&gt;
Changing constraint enforcement parameters has no effect on existing table constraints that omit &lt;code&gt;ENABLED&lt;/code&gt; or &lt;code&gt;DISABLED&lt;/code&gt;. These table constraints retain the enforcement settings that they previously acquired. You can change the enforcement settings on these constraints only with
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-table/#AlterConstraint&#34;&gt;ALTER TABLE...ALTER CONSTRAINT&lt;/a&gt;&lt;/code&gt;.
&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The following &lt;code&gt;CREATE TABLE&lt;/code&gt; statement creates table &lt;code&gt;new_sales&lt;/code&gt; with columns &lt;code&gt;order_id&lt;/code&gt; and &lt;code&gt;order_qty&lt;/code&gt;, which are defined with constraints &lt;code&gt;PRIMARY KEY&lt;/code&gt; and &lt;code&gt;CHECK&lt;/code&gt;, respectively:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE new_sales ( order_id int PRIMARY KEY, order_qty int CHECK (order_qty &amp;gt; 0) );
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Neither constraint is explicitly enabled or disabled, so the database uses configuration parameters &lt;code&gt;EnableNewPrimaryKeysByDefault&lt;/code&gt; and &lt;code&gt;EnableNewCheckConstraintsByDefault&lt;/code&gt; to set enforcement in the table definition:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SHOW CURRENT EnableNewPrimaryKeysByDefault, EnableNewCheckConstraintsByDefault;
  level  |                name                | setting
---------+------------------------------------+---------
 DEFAULT | EnableNewPrimaryKeysByDefault      | 0
 DEFAULT | EnableNewCheckConstraintsByDefault | 1
(2 rows)

=&amp;gt; SELECT EXPORT_TABLES(&amp;#39;&amp;#39;,&amp;#39;new_sales&amp;#39;);
...

CREATE TABLE public.new_sales
(
    order_id int NOT NULL,
    order_qty int,
    CONSTRAINT C_PRIMARY PRIMARY KEY (order_id) DISABLED,
    CONSTRAINT C_CHECK CHECK ((new_sales.order_qty &amp;gt; 0)) ENABLED
);

(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In this case, changing &lt;code&gt;EnableNewPrimaryKeysByDefault&lt;/code&gt; to 1 (enabled) has no effect on the &lt;code&gt;C_PRIMARY&lt;/code&gt; constraint in table &lt;code&gt;new_sales&lt;/code&gt;. You can enforce this constraint with &lt;code&gt;ALTER TABLE...ALTER CONSTRAINT&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER TABLE public.new_sales ALTER CONSTRAINT C_PRIMARY ENABLED;
ALTER TABLE
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Admin: Verifying constraint enforcement</title>
      <link>/en/admin/constraints/constraint-enforcement/verifying-constraint-enforcement/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/constraints/constraint-enforcement/verifying-constraint-enforcement/</guid>
      <description>
        
        
        &lt;p&gt;SHOW CURRENT can return the settings of constraint enforcement parameters:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SHOW CURRENT EnableNewCheckConstraintsByDefault, EnableNewUniqueKeysByDefault, EnableNewPrimaryKeysByDefault;
  level   |                name                | setting
----------+------------------------------------+---------
 DEFAULT  | EnableNewCheckConstraintsByDefault | 1
 DEFAULT  | EnableNewUniqueKeysByDefault       | 0
 DATABASE | EnableNewPrimaryKeysByDefault      | 1
(3 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can also query the following system tables to check table enforcement settings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/constraint-columns/#&#34;&gt;CONSTRAINT_COLUMNS&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/table-constraints/#&#34;&gt;TABLE_CONSTRAINTS&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/primary-keys/#&#34;&gt;PRIMARY_KEYS&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, the following statement queries &lt;code&gt;TABLE_CONSTRAINTS&lt;/code&gt; and returns all constraints in database tables. Column &lt;code&gt;is_enabled&lt;/code&gt; is set to true or false for all constraints that can be enabled or disabled—&lt;code&gt;PRIMARY KEY&lt;/code&gt;, &lt;code&gt;UNIQUE&lt;/code&gt;, and &lt;code&gt;CHECK&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT constraint_name, table_name, constraint_type, is_enabled FROM table_constraints ORDER BY is_enabled, table_name;
      constraint_name      |      table_name       | constraint_type | is_enabled
---------------------------+-----------------------+-----------------+------------
 C_PRIMARY                 | call_center_dimension | p               | f
 C_PRIMARY                 | date_dimension        | p               | f
 C_PRIMARY                 | employee_dimension    | p               | f
 C_PRIMARY                 | online_page_dimension | p               | f
 C_PRIMARY                 | product_dimension     | p               | f
 C_PRIMARY                 | promotion_dimension   | p               | f
 C_PRIMARY                 | shipping_dimension    | p               | f
 C_PRIMARY                 | store_dimension       | p               | f
 C_UNIQUE_1                | tabletemp             | u               | f
 C_PRIMARY                 | vendor_dimension      | p               | f
 C_PRIMARY                 | warehouse_dimension   | p               | f
 C_PRIMARY                 | customer_dimension    | p               | t
 C_PRIMARY                 | new_sales             | p               | t
 C_CHECK                   | new_sales             | c               | t
 fk_inventory_date         | inventory_fact        | f               |
 fk_inventory_product      | inventory_fact        | f               |
 fk_inventory_warehouse    | inventory_fact        | f               |
 ...
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following query returns all tables that have primary key, unique, and check constraints, and shows whether the constraints are enabled:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT table_name, constraint_name, constraint_type, is_enabled FROM constraint_columns
   WHERE constraint_type in (&amp;#39;p&amp;#39;, &amp;#39;u&amp;#39;, &amp;#39;c&amp;#39;)
   ORDER BY table_name, constraint_type;
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT table_name, constraint_name, constraint_type, is_enabled FROM constraint_columns WHERE constraint_type in (&amp;#39;p&amp;#39;, &amp;#39;u&amp;#39;, &amp;#39;c&amp;#39;) ORDER BY table_name, constraint_type;
      table_name       | constraint_name | constraint_type | is_enabled
-----------------------+-----------------+-----------------+------------
 call_center_dimension | C_PRIMARY       | p               | f
 customer_dimension    | C_PRIMARY       | p               | t
 customer_dimension2   | C_PRIMARY       | p               | t
 customer_dimension2   | C_PRIMARY       | p               | t
 date_dimension        | C_PRIMARY       | p               | f
 employee_dimension    | C_PRIMARY       | p               | f
 new_sales             | C_CHECK         | c               | t
 new_sales             | C_PRIMARY       | p               | t
 ...
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Admin: Reporting constraint violations</title>
      <link>/en/admin/constraints/constraint-enforcement/reporting-constraint-violations/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/constraints/constraint-enforcement/reporting-constraint-violations/</guid>
      <description>
        
        
        &lt;p&gt;OpenText™ Analytics Database reports constraint violations in two cases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;ALTER TABLE&lt;/code&gt; tries to enable constraint enforcement on a table that already contains data, and the data does not comply with the constraint.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A DML operation tries to add or update data on a table with enforced constraints, and the new data does not comply with one or more constraints.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;ddl-constraint-violations&#34;&gt;DDL constraint violations&lt;/h2&gt;
&lt;p&gt;When you enable constraint enforcement on an existing table with 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-table/#AddConstraint&#34;&gt;ALTER TABLE...ADD CONSTRAINT&lt;/a&gt;&lt;/code&gt; or 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-table/#AlterConstraint&#34;&gt;ALTER TABLE...ALTER CONSTRAINT&lt;/a&gt;&lt;/code&gt;, the database applies that constraint immediately to the table&#39;s current content. If the database detects constraint violations, an error displays that reports on violations and then rolls back the &lt;code&gt;ALTER TABLE&lt;/code&gt; statement.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER TABLE public.customer_dimension ADD CONSTRAINT unique_cust_types UNIQUE (customer_type) ENABLED;
ERROR 6745:  Duplicate key values: &amp;#39;customer_type=Company&amp;#39;
-- violates constraint &amp;#39;public.customer_dimension.unique_cust_types&amp;#39;
DETAIL:  Additional violations:
Constraint &amp;#39;public.customer_dimension.unique_cust_types&amp;#39;:
duplicate key values: &amp;#39;customer_type=Individual&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;dml-constraint-violations&#34;&gt;DML constraint violations&lt;/h2&gt;
&lt;p&gt;When you invoke &lt;a href=&#34;../../../../en/admin/constraints/constraint-enforcement/#OperationsInvokeEnforcement&#34;&gt;DML operations&lt;/a&gt; that add or update data on a table with enforced constraints, the database checks that the new data complies with these constraints. If the database detects constraint violations, the operation returns with an error that reports on violations, and then rolls back.&lt;/p&gt;
&lt;p&gt;For example, table &lt;code&gt;store_orders&lt;/code&gt; and &lt;code&gt;store_orders_2015&lt;/code&gt; are defined with the same primary key and check constraints. Both tables enable enforcement of the primary key constraint; only &lt;code&gt;store_orders_2015&lt;/code&gt; enforces the check constraint:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CREATE TABLE public.store_orders
(
    order_no int NOT NULL,
    order_date timestamp NOT NULL,
    shipper varchar(20),
    ship_date date
)
PARTITION BY ((date_part(&amp;#39;year&amp;#39;, store_orders.order_date))::int);

ALTER TABLE public.store_orders ADD CONSTRAINT C_PRIMARY PRIMARY KEY (order_no) ENABLED;
ALTER TABLE public.store_orders ADD CONSTRAINT C_CHECK CHECK (((date_part(&amp;#39;year&amp;#39;, store_orders.order_date))::int = 2014)) DISABLED;

CREATE TABLE public.store_orders_2015
(
    order_no int NOT NULL,
    order_date timestamp NOT NULL,
    shipper varchar(20),
    ship_date date
)
PARTITION BY ((date_part(&amp;#39;year&amp;#39;, store_orders_2015.order_date))::int);

ALTER TABLE public.store_orders_2015 ADD CONSTRAINT C_PRIMARY PRIMARY KEY (order_no) ENABLED;
ALTER TABLE public.store_orders_2015 ADD CONSTRAINT C_CHECK CHECK (((date_part(&amp;#39;year&amp;#39;, store_orders_2015.order_date))::int = 2015)) ENABLED;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you try to insert data with duplicate key values into &lt;code&gt;store_orders&lt;/code&gt;, the insert operation returns with an error message. The message contains detailed information about the first violation. It also returns abbreviated information about subsequent violations, up to the first 30. If necessary , the error message also includes a note that more than 30 violations occurred:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; INSERT INTO store_orders SELECT order_number, date_ordered, shipper_name, date_shipped FROM store.store_orders_fact;
ERROR 6745:  Duplicate key values: &amp;#39;order_no=10&amp;#39; -- violates constraint &amp;#39;public.store_orders.C_PRIMARY&amp;#39;
DETAIL:  Additional violations:
Constraint &amp;#39;public.store_orders.C_PRIMARY&amp;#39;:
duplicate key values:
&amp;#39;order_no=11&amp;#39;; &amp;#39;order_no=12&amp;#39;; &amp;#39;order_no=13&amp;#39;; &amp;#39;order_no=14&amp;#39;; &amp;#39;order_no=15&amp;#39;; &amp;#39;order_no=17&amp;#39;;
&amp;#39;order_no=21&amp;#39;; &amp;#39;order_no=23&amp;#39;; &amp;#39;order_no=26&amp;#39;; &amp;#39;order_no=27&amp;#39;; &amp;#39;order_no=29&amp;#39;; &amp;#39;order_no=33&amp;#39;;
&amp;#39;order_no=35&amp;#39;; &amp;#39;order_no=38&amp;#39;; &amp;#39;order_no=39&amp;#39;; &amp;#39;order_no=4&amp;#39;; &amp;#39;order_no=41&amp;#39;; &amp;#39;order_no=46&amp;#39;;
&amp;#39;order_no=49&amp;#39;; &amp;#39;order_no=6&amp;#39;; &amp;#39;order_no=62&amp;#39;; &amp;#39;order_no=67&amp;#39;; &amp;#39;order_no=68&amp;#39;; &amp;#39;order_no=70&amp;#39;;
&amp;#39;order_no=72&amp;#39;; &amp;#39;order_no=75&amp;#39;; &amp;#39;order_no=76&amp;#39;; &amp;#39;order_no=77&amp;#39;; &amp;#39;order_no=79&amp;#39;;
Note: there were additional errors
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Similarly, the following attempt to copy data from &lt;code&gt;store_orders&lt;/code&gt; into &lt;code&gt;store_orders_2015&lt;/code&gt; violates the table&#39;s check constraint. It returns with an error message like the one shown earlier:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SELECT COPY_TABLE(&amp;#39;store_orders&amp;#39;, &amp;#39;store_orders_2015&amp;#39;);
NOTICE 7636:  Validating enabled constraints on table &amp;#39;public.store_orders_2015&amp;#39;...
ERROR 7231:  Check constraint &amp;#39;public.store_orders_2015.C_CHECK&amp;#39; ((date_part(&amp;#39;year&amp;#39;, store_orders_2015.order_date))::int = 2015)
violation in table &amp;#39;public.store_orders_2015&amp;#39;: &amp;#39;order_no=101,order_date=2007-05-02 00:00:00&amp;#39;
DETAIL:  Additional violations:
Check constraint &amp;#39;public.store_orders_2015.C_CHECK&amp;#39;:violations:
&amp;#39;order_no=106,order_date=2016-07-01 00:00:00&amp;#39;; &amp;#39;order_no=119,order_date=2016-01-04 00:00:00&amp;#39;;
&amp;#39;order_no=14,order_date=2016-07-01 00:00:00&amp;#39;; &amp;#39;order_no=154,order_date=2016-11-06 00:00:00&amp;#39;;
&amp;#39;order_no=156,order_date=2016-04-10 00:00:00&amp;#39;; &amp;#39;order_no=171,order_date=2016-10-08 00:00:00&amp;#39;;
&amp;#39;order_no=203,order_date=2016-03-01 00:00:00&amp;#39;; &amp;#39;order_no=204,order_date=2016-06-09 00:00:00&amp;#39;;
&amp;#39;order_no=209,order_date=2016-09-07 00:00:00&amp;#39;; &amp;#39;order_no=214,order_date=2016-11-02 00:00:00&amp;#39;;
&amp;#39;order_no=223,order_date=2016-12-08 00:00:00&amp;#39;; &amp;#39;order_no=227,order_date=2016-08-02 00:00:00&amp;#39;;
&amp;#39;order_no=240,order_date=2016-03-09 00:00:00&amp;#39;; &amp;#39;order_no=262,order_date=2016-02-09 00:00:00&amp;#39;;
&amp;#39;order_no=280,order_date=2016-10-10 00:00:00&amp;#39;;
Note: there were additional errors
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a href=&#34;../../../../en/admin/partitioning-tables/managing-partitions/&#34;&gt;Partition management functions&lt;/a&gt; that add or update table content must also respect enforced constraints in the target table. For example, the following 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/partition-functions/move-partitions-to-table/#&#34;&gt;MOVE_PARTITIONS_TO_TABLE&lt;/a&gt;&lt;/code&gt; operation attempts to move a partition from &lt;code&gt;store_orders&lt;/code&gt; into &lt;code&gt;store_orders_2015&lt;/code&gt;. However, the source partition includes data that violates the target table&#39;s check constraint. Thus, the function returns with results that indicate it failed to move any data:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MOVE_PARTITIONS_TO_TABLE (&amp;#39;store_orders&amp;#39;,&amp;#39;2014&amp;#39;,&amp;#39;2014&amp;#39;,&amp;#39;store_orders_2015&amp;#39;);
NOTICE 7636:  Validating enabled constraints on table &amp;#39;public.store_orders_2015&amp;#39;...
             MOVE_PARTITIONS_TO_TABLE
--------------------------------------------------
 0 distinct partition values moved at epoch 204.
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Admin: Constraint enforcement and locking</title>
      <link>/en/admin/constraints/constraint-enforcement/constraint-enforcement-and-locking/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/constraints/constraint-enforcement/constraint-enforcement-and-locking/</guid>
      <description>
        
        
        &lt;p&gt;OpenText™ Analytics Database uses an insert/validate (IV) lock for &lt;a href=&#34;../../../../en/admin/constraints/constraint-enforcement/#OperationsInvokeEnforcement&#34;&gt;DML operations&lt;/a&gt; that require validation for enabled primary key and unique constraints.&lt;/p&gt;
&lt;p&gt;When you run these operations on tables that enforce primary or unique key constraints, the database sets locks on the tables as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Sets an I (insert) lock in order to load data. Multiple sessions can acquire an I lock on the same table simultaneously, and load data concurrently.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sets an IV lock on the table to validate the loaded data against table primary and unique constraints. Only one session at a time can acquire an IV lock on a given table. Other sessions that need to access this table are blocked until the IV lock is released.				A session retains its IV lock until one of two events occur:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Validation is complete and the DML operation is committed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A constraint violation is detected and the operation is rolled back.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In either case, OpenText™ Analytics Database releases the IV lock.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;iv-lock-blocking&#34;&gt;IV lock blocking&lt;/h2&gt;
&lt;p&gt;While the database validates a table&#39;s primary or unique key constraints, it temporarily blocks other DML operations on the table. These delays can be especially noticeable when multiple sessions concurrently try to perform extensive changes to data on the same table.&lt;/p&gt;
&lt;p&gt;For example, each of three concurrent sessions attempts to load data into table &lt;code&gt;t1&lt;/code&gt;, as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;All three session acquire an I lock on &lt;code&gt;t1&lt;/code&gt; and begin to load data into the table.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Session 2 acquires an exclusive IV lock on &lt;code&gt;t1&lt;/code&gt; to validate table constraints on the data that it loaded. Only one session at a time can acquire an IV lock on a table, so sessions 1 and 3 must wait for session 2 to complete validation before they can begin their own validation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Session 2 successfully validates all data that it loaded into &lt;code&gt;t1&lt;/code&gt;. On committing its load transaction, it releases its IV lock on the table.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Session 1 acquires an IV lock on &lt;code&gt;t1&lt;/code&gt; and begins to validate the data that it loaded. In this case, the database detects a constraint violation and rolls back the load transaction. Session 1 releases its IV lock on &lt;code&gt;t1&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Session 3 now acquires an IV lock on &lt;code&gt;t1&lt;/code&gt; and begins to validate the data that it loaded. On completing validation, session 3 commits its load transaction and releases the IV lock on &lt;code&gt;t1&lt;/code&gt;. The table is now available for other DML operations.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;p&gt;For information on lock modes and compatibility and conversion matrices, see &lt;a href=&#34;../../../../en/admin/db-locks/lock-modes/#&#34;&gt;Lock modes&lt;/a&gt;. See also &lt;a href=&#34;../../../../en/sql-reference/system-tables/v-monitor-schema/locks/#&#34;&gt;LOCKS&lt;/a&gt; and &lt;a href=&#34;../../../../en/sql-reference/system-tables/v-monitor-schema/lock-usage/#&#34;&gt;LOCK_USAGE&lt;/a&gt;.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Constraint enforcement and performance</title>
      <link>/en/admin/constraints/constraint-enforcement/constraint-enforcement-and-performance/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/constraints/constraint-enforcement/constraint-enforcement-and-performance/</guid>
      <description>
        
        
        &lt;p&gt;In some cases, constraint enforcement can significantly affect overall system performance. This is especially true when constraints are enforced on large fact tables that are subject to frequent and concurrent bulk updates. Every update operation that &lt;a href=&#34;../../../../en/admin/constraints/constraint-enforcement/#OperationsInvokeEnforcement&#34;&gt;invokes constraint enforcement &lt;/a&gt;requires OpenText™ Analytics Database to check each table row for all constraint violations. Thus, enforcing multiple constraints on a table with a large amount of data can cause noticeable delays.&lt;/p&gt;
&lt;p&gt;To minimize the overhead incurred by enforcing constraints, omit constraint enforcement on large, often updated tables. You can evaluate these tables for constraint violations by running 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/table-functions/analyze-constraints/#&#34;&gt;ANALYZE_CONSTRAINTS&lt;/a&gt;&lt;/code&gt; during off-peak hours.&lt;/p&gt;
&lt;p&gt;Several aspects of constraint enforcement have specific impact on system performance. These include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#Table&#34;&gt;Table locking&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#Enforced&#34;&gt;Projections for enforced constraints&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;#Rollback&#34;&gt;Constraint-triggered rollback within transactions&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name=&#34;Table&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;table-locking&#34;&gt;Table locking&lt;/h2&gt;
&lt;p&gt;If a table enforces constraints, the database sets an insert/validate (IV) lock on that table during a DML operation while it undergoes validation. Only one session at a time can acquire an IV lock on that table. As long as the session retains this lock, no other session can access the table. Lengthy loads is liable to cause performance bottlenecks, especially if multiple sessions try to load the same table simultaneously. For details, see &lt;a href=&#34;../../../../en/admin/constraints/constraint-enforcement/constraint-enforcement-and-locking/#&#34;&gt;Constraint enforcement and locking&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a name=&#34;Enforced&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;enforced-constraint-projections&#34;&gt;Enforced constraint projections&lt;/h2&gt;
&lt;p&gt;To enforce primary key and unique constraints, the database creates &lt;a href=&#34;../../../../en/admin/constraints/constraint-enforcement/projections-enforced-constraints/&#34;&gt;special projections&lt;/a&gt; that it uses to validate data. Depending on the amount of data in the anchor table, creating the projection might incur significant system overhead.&lt;/p&gt;
&lt;p&gt;&lt;a name=&#34;Rollback&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;rollback-in-transactions&#34;&gt;Rollback in transactions&lt;/h2&gt;
&lt;p&gt;The database validates enforced constraints for each SQL statement, and rolls back each statement that encounters a constraint violation. You cannot defer enforcement until the transaction commits. Thus, if multiple DML statements comprise a single transaction, the database validates each statement separately for constraint compliance, and rolls back any statement that fails validation. It commits the transaction only after all statements in it return.&lt;/p&gt;
&lt;p&gt;For example, you might issue ten &lt;code&gt;INSERT&lt;/code&gt; statements as a single transaction on a table that enforces &lt;code&gt;UNIQUE&lt;/code&gt; on one of its columns. If the sixth statement attempts to insert a duplicate value in that column, that statement is rolled back. However, the other statements can commit.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Projections for enforced constraints</title>
      <link>/en/admin/constraints/constraint-enforcement/projections-enforced-constraints/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/constraints/constraint-enforcement/projections-enforced-constraints/</guid>
      <description>
        
        
        &lt;p&gt;To enforce primary key and unique constraints, OpenText™ Analytics Database creates special constraint enforcement projections that it uses to validate new and updated data. If you add a constraint on an empty table, the database creates a constraint enforcement projection for that table only when data is added to it. If you add a primary key or unique constraint to a populated table and enable enforcement, the database chooses an existing projection to enforce the constraint, if one exists. Otherwise, the database creates a projection for that constraint. If a constraint violation occurs, the database rolls back the statement and any projection it created for the constraint.&lt;/p&gt;
&lt;p&gt;If you drop an enforced primary key or unique constraint, the database automatically drops the projection associated with that constraint. You can also explicitly drop constraint projections with 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/drop-statements/drop-projection/#&#34;&gt;DROP PROJECTION&lt;/a&gt;&lt;/code&gt;. If the statement omits &lt;code&gt;CASCADE&lt;/code&gt;, the database issues a warning about dropping this projection for an enabled constraint; otherwise, it silently drops the projection. In either case, the next time the database needs to enforce this constraint, it recreates the projection. Depending on the amount of data in the anchor table, creating the projection can incur significant overhead.&lt;/p&gt;
&lt;p&gt;You can query system table 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/projections/#&#34;&gt;PROJECTIONS&lt;/a&gt;&lt;/code&gt; on Boolean column &lt;code&gt;IS_KEY_CONSTRAINT_PROJECTION&lt;/code&gt; to obtain constraint-specific projections.

&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;

Constraint enforcement projections in a table can significantly facilitate its analysis by
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/table-functions/analyze-constraints/#&#34;&gt;ANALYZE_CONSTRAINTS&lt;/a&gt;&lt;/code&gt;.

&lt;/div&gt;&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Constraint enforcement limitations</title>
      <link>/en/admin/constraints/constraint-enforcement/constraint-enforcement-limitations/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/constraints/constraint-enforcement/constraint-enforcement-limitations/</guid>
      <description>
        
        
        &lt;p&gt;OpenText™ Analytics Database does not support constraint enforcement for foreign keys or external tables. Restrictions also apply to temporary tables.&lt;/p&gt;
&lt;h2 id=&#34;foreign-keys&#34;&gt;Foreign keys&lt;/h2&gt;
&lt;p&gt;OpenText™ Analytics Database does not support enforcement of foreign keys and referential integrity. Thus, it is possible to load data that can return errors in the following cases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;An inner join query is processed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;An outer join is treated as an inner join due to the presence of foreign keys.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To validate foreign key constraints, use 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/table-functions/analyze-constraints/#&#34;&gt;ANALYZE_CONSTRAINTS&lt;/a&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;external-tables&#34;&gt;External tables&lt;/h2&gt;
&lt;p&gt;The database does not support automatic enforcement of constraints on external tables.&lt;/p&gt;
&lt;h2 id=&#34;local-temporary-tables&#34;&gt;Local temporary tables&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;ALTER TABLE&lt;/code&gt; can set enforcement on a primary key or unique constraint in a local temporary table only if the table contains no data. If you try to enforce a constraint in a table that contains data, &lt;code&gt;ALTER TABLE&lt;/code&gt; returns an error.&lt;/p&gt;
&lt;h2 id=&#34;global-temporary-tables&#34;&gt;Global temporary tables&lt;/h2&gt;
&lt;p&gt;In a global temporary table, you set enforcement on a primary key or unique constraint only with &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-temporary-table/#&#34;&gt;CREATE TEMPORARY TABLE&lt;/a&gt;. &lt;code&gt;ALTER TABLE&lt;/code&gt; returns an error if you try to set enforcement on a primary key or unique constraint in an existing table, whether populated or empty.

&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;

You can always use &lt;code&gt;ALTER TABLE...DROP CONSTRAINT&lt;/code&gt; to disable primary and unique key constraints in local and global temporary tables.

&lt;/div&gt;&lt;/p&gt;

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