Oracle 23.26SQLLab-verified · 2026-12-01

ORA-02290: check constraint violated

The INSERT or UPDATE would store a row that fails the table's CHECK condition.

Oracle AI Database 26ai Free 23.26.3.0.0
ORA-02290: check constraint (LAB_A.CK_ORDERS_STATUS) violated

Jump to a cause

  1. 01The value is not in the allowed list (including upper/lower case)
  2. 02An UPDATE makes some row break the condition
  3. 03A two-column rule fails (end date before start date)
  4. 04The CHECK has no name, so the message only shows SYS_C…
  5. 05INSERT ... SELECT from a staging table with lowercase or padded values
  6. 06Broken JSON in a column with CHECK (payload IS JSON)
  7. 07A new status value was added in the app, but not to the CHECK list

Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-12-01 · container image gvenzl/oracle-free:23-slim

ORA-02290 means a row did not pass a CHECK constraint. The message names the constraint, for example (LAB_A.CK_ORDERS_STATUS). Look up its condition in USER_CONSTRAINTS and compare it with the value you are saving.

In the lab the causes were a value not in the allowed list, a new status value the CHECK list was never updated for, an UPDATE that pushed a quantity below 0, an end date earlier than the start date, lowercase or padded values in a staging table loaded with INSERT ... SELECT, and broken JSON in an IS JSON column. An unnamed CHECK shows up only as a number like SYS_C0011638; look it up by table name.

01The value is not in the allowed list (including upper/lower case)

The status column only allows 'NEW', 'PAID', 'SHIPPED'. INSERT ... VALUES (1, 'new'); failed with check constraint (LAB_A.CK_ORDERS_STATUS) violated. String comparison is case-sensitive, so 'new' is not 'NEW'.

The condition from USER_CONSTRAINTS was status IN ('NEW', 'PAID', 'SHIPPED'). Inserting 'NEW' worked.

Setup
Setuprun as lab_a
CREATE TABLE orders (
  order_id NUMBER PRIMARY KEY,
  status   VARCHAR2(10) CONSTRAINT ck_orders_status CHECK (status IN ('NEW', 'PAID', 'SHIPPED'))
);
OUTPUT
Table created.
Reproducerun as lab_a
INSERT INTO orders (order_id, status) VALUES (1, 'new');
✕ ERROR
INSERT INTO orders (order_id, status) VALUES (1, 'new')
*
ERROR at line 1:
ORA-02290: check constraint (LAB_A.CK_ORDERS_STATUS) violated
Help: https://docs.oracle.com/error-help/db/ora-02290/
Check the causerun as lab_a
SELECT constraint_name, CAST(search_condition_vc AS VARCHAR2(50)) AS condition FROM user_constraints WHERE constraint_name = 'CK_ORDERS_STATUS';
OUTPUT
CONSTRAINT_NAME                CONDITION
------------------------------ --------------------------------------------------
CK_ORDERS_STATUS               status IN ('NEW', 'PAID', 'SHIPPED')

1 row selected.

Read the condition with SELECT search_condition_vc FROM user_constraints WHERE constraint_name = '...' and send a value from the list.

Fix: run the corrected statementrun as lab_a
INSERT INTO orders (order_id, status) VALUES (1, 'NEW');
SELECT order_id, status FROM orders;
✓ SUCCESS
1 row created.


  ORDER_ID STATUS
---------- ------------------------------
         1 NEW

1 row selected.

02An UPDATE makes some row break the condition

stock has CHECK (qty >= 0). UPDATE stock SET qty = qty - 10; failed, because item 1 had only 5 and would become -5. One bad row is enough: the whole UPDATE fails, and item 2 (30) was not changed either.

Limiting the rows with WHERE qty >= 10 updated 1 row: item 2 became 20 and item 1 stayed at 5.

Setup
Setuprun as lab_a
CREATE TABLE stock (
  item_id NUMBER PRIMARY KEY,
  qty     NUMBER CONSTRAINT ck_stock_qty CHECK (qty >= 0)
);
INSERT INTO stock VALUES (1, 5);
INSERT INTO stock VALUES (2, 30);
COMMIT;
OUTPUT
Table created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
UPDATE stock SET qty = qty - 10;
✕ ERROR
UPDATE stock SET qty = qty - 10
*
ERROR at line 1:
ORA-02290: check constraint (LAB_A.CK_STOCK_QTY) violated
Help: https://docs.oracle.com/error-help/db/ora-02290/
Check the causerun as lab_a
COLUMN constraint_name FORMAT A14
COLUMN condition FORMAT A12
SELECT constraint_name, CAST(search_condition_vc AS VARCHAR2(12)) AS condition FROM user_constraints WHERE table_name = 'STOCK' AND constraint_type = 'C';
OUTPUT
CONSTRAINT_NAM CONDITION
-------------- ------------
CK_STOCK_QTY   qty >= 0

1 row selected.

CK_STOCK_QTY only allows qty >= 0. Subtracting 10 from every row breaks this rule for any item with less than 10 in stock.

Checkrun as lab_a
SELECT item_id, qty, qty - 10 AS after_update FROM stock ORDER BY item_id;
OUTPUT
   ITEM_ID        QTY AFTER_UPDATE
---------- ---------- ------------
         1          5           -5
         2         30           20

2 rows selected.

Before a bulk UPDATE, check the values it would produce with a SELECT, and exclude rows that would break the rule.

After the fixrun as lab_a
UPDATE stock SET qty = qty - 10 WHERE qty >= 10;
SELECT item_id, qty FROM stock ORDER BY item_id;
✓ SUCCESS
1 row updated.


   ITEM_ID        QTY
---------- ----------
         1          5
         2         20

2 rows selected.

03A two-column rule fails (end date before start date)

leave_requests has CHECK (end_date >= start_date). Inserting start 2026-12-24 and end 2026-12-22 failed with CK_LEAVE_DATES. Both are valid dates; only the order is wrong, which often happens when the two values are passed in the wrong order.

Swapping them (start 2026-12-22, end 2026-12-24) inserted the row.

Setup
Setuprun as lab_a
CREATE TABLE leave_requests (
  req_id     NUMBER PRIMARY KEY,
  start_date DATE NOT NULL,
  end_date   DATE NOT NULL,
  CONSTRAINT ck_leave_dates CHECK (end_date >= start_date)
);
OUTPUT
Table created.
Reproducerun as lab_a
INSERT INTO leave_requests VALUES (1, DATE '2026-12-24', DATE '2026-12-22');
✕ ERROR
INSERT INTO leave_requests VALUES (1, DATE '2026-12-24', DATE '2026-12-22')
*
ERROR at line 1:
ORA-02290: check constraint (LAB_A.CK_LEAVE_DATES) violated
Help: https://docs.oracle.com/error-help/db/ora-02290/
Check the causerun as lab_a
SELECT constraint_name, CAST(search_condition_vc AS VARCHAR2(50)) AS condition FROM user_constraints WHERE table_name = 'LEAVE_REQUESTS' AND constraint_name = 'CK_LEAVE_DATES';
OUTPUT
CONSTRAINT_NAME                CONDITION
------------------------------ --------------------------------------------------
CK_LEAVE_DATES                 end_date >= start_date

1 row selected.

When the condition compares two columns, check the order of the values, not just each value.

Fix: run the corrected statementrun as lab_a
INSERT INTO leave_requests VALUES (1, DATE '2026-12-22', DATE '2026-12-24');
SELECT req_id, TO_CHAR(start_date, 'YYYY-MM-DD') AS start_date, TO_CHAR(end_date, 'YYYY-MM-DD') AS end_date FROM leave_requests;
✓ SUCCESS
1 row created.


    REQ_ID START_DATE END_DATE
---------- ---------- ----------
         1 2026-12-22 2026-12-24

1 row selected.

04The CHECK has no name, so the message only shows SYS_C…

payments was created with amount NUMBER CHECK (amount > 0) and no constraint name. Inserting 0 failed with check constraint (LAB_A.SYS_C0011638) violated. The name tells you nothing; the number is generated and differs on every database.

Querying user_constraints by table name and constraint_type = 'C' showed that SYS_C0011638 is amount > 0. Inserting 15000 worked. The constraint was then renamed to CK_PAYMENTS_AMOUNT with ALTER TABLE ... RENAME CONSTRAINT, so the next error will say what it checks.

Setup
Setuprun as lab_a
CREATE TABLE payments (
  pay_id NUMBER PRIMARY KEY,
  amount NUMBER CHECK (amount > 0)
);
OUTPUT
Table created.
Reproducerun as lab_a
INSERT INTO payments VALUES (1, 0);
✕ ERROR
INSERT INTO payments VALUES (1, 0)
*
ERROR at line 1:
ORA-02290: check constraint (LAB_A.SYS_C0011638) violated
Help: https://docs.oracle.com/error-help/db/ora-02290/
Check the causerun as lab_a
COLUMN constraint_name FORMAT A20
COLUMN condition FORMAT A30
SELECT constraint_name, CAST(search_condition_vc AS VARCHAR2(30)) AS condition FROM user_constraints WHERE table_name = 'PAYMENTS' AND constraint_type = 'C';
OUTPUT
CONSTRAINT_NAME      CONDITION
-------------------- ------------------------------
SYS_C0011638         amount > 0

1 row selected.

The name from the error message, SYS_C0011638, appears here with its condition: amount > 0.

Fixrun as lab_a
BEGIN
  FOR c IN (SELECT constraint_name FROM user_constraints WHERE table_name = 'PAYMENTS' AND constraint_type = 'C' AND constraint_name LIKE 'SYS_C%') LOOP
    EXECUTE IMMEDIATE 'ALTER TABLE payments RENAME CONSTRAINT ' || c.constraint_name || ' TO ck_payments_amount';
  END LOOP;
END;
/
OUTPUT
PL/SQL procedure successfully completed.

Look up SYS_C names by table (constraint_type = 'C'), and name constraints when you create them: CONSTRAINT ck_payments_amount CHECK (amount > 0).

After the fixrun as lab_a
INSERT INTO payments VALUES (1, 15000);
SELECT pay_id, amount FROM payments;
SELECT constraint_name FROM user_constraints WHERE table_name = 'PAYMENTS' AND constraint_type = 'C';
✓ SUCCESS
1 row created.


    PAY_ID     AMOUNT
---------- ----------
         1      15000

1 row selected.


CONSTRAINT_NAME
------------------------------
CK_PAYMENTS_AMOUNT

1 row selected.

05INSERT ... SELECT from a staging table with lowercase or padded values

Four rows loaded into orders_stage were copied with INSERT INTO orders ... SELECT ... FROM orders_stage;. The statement failed on CK_ORDERS_STATUS, and the error does not say which row broke the rule.

Running the CHECK condition the other way round on the staging table found two rows: [paid] (lowercase) and [SHIPPED ] with length 8, a trailing space. After UPDATE orders_stage SET status = UPPER(TRIM(status)) changed those 2 rows, the same INSERT created 4 rows.

Setup
Setuprun as lab_a
CREATE TABLE orders (
  order_id NUMBER PRIMARY KEY,
  status   VARCHAR2(10) CONSTRAINT ck_orders_status CHECK (status IN ('NEW', 'PAID', 'SHIPPED'))
);
CREATE TABLE orders_stage (order_id NUMBER, status VARCHAR2(10));
INSERT INTO orders_stage VALUES (1, 'NEW');
INSERT INTO orders_stage VALUES (2, 'paid');
INSERT INTO orders_stage VALUES (3, 'SHIPPED ');
INSERT INTO orders_stage VALUES (4, 'PAID');
COMMIT;
OUTPUT
Table created.


Table created.


1 row created.


1 row created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
INSERT INTO orders (order_id, status)
SELECT order_id, status FROM orders_stage;
✕ ERROR
INSERT INTO orders (order_id, status)
*
ERROR at line 1:
ORA-02290: check constraint (LAB_A.CK_ORDERS_STATUS) violated
Help: https://docs.oracle.com/error-help/db/ora-02290/
Check the causerun as lab_a
SELECT order_id, '[' || status || ']' AS status, LENGTH(status) AS len
  FROM orders_stage
 WHERE status NOT IN ('NEW', 'PAID', 'SHIPPED')
 ORDER BY order_id;
OUTPUT
  ORDER_ID STATUS                                LEN
---------- ------------------------------ ----------
         2 [paid]                                  4
         3 [SHIPPED ]                              8

2 rows selected.

Rows 2 and 3 are outside the allowed list. The brackets and LEN show why: paid is lowercase and SHIPPED is 8 characters because of a trailing space.

Fixrun as lab_a
UPDATE orders_stage SET status = UPPER(TRIM(status))
 WHERE status NOT IN ('NEW', 'PAID', 'SHIPPED');
COMMIT;
OUTPUT
2 rows updated.


Commit complete.

Before a bulk load, query the staging table with the opposite of the CHECK condition to find the bad rows, then clean them.

After the fixrun as lab_a
INSERT INTO orders (order_id, status)
SELECT order_id, status FROM orders_stage;
SELECT order_id, status FROM orders ORDER BY order_id;
✓ SUCCESS
4 rows created.


  ORDER_ID STATUS
---------- ------------------------------
         1 NEW
         2 PAID
         3 SHIPPED
         4 PAID

4 rows selected.

06Broken JSON in a column with CHECK (payload IS JSON)

api_log.payload has CHECK (payload IS JSON). The value {"order_id": 100, "status": "PAID" is missing its closing brace, so the INSERT failed with ORA-02290 on CK_API_LOG_JSON. The message does not mention JSON; only the constraint name hints at it.

The same string tested with IS JSON in a CASE returned INVALID, and with the closing } it returned VALID. That value was inserted, and JSON_VALUE(payload, '$.status') returned PAID.

Setup
Setuprun as lab_a
CREATE TABLE api_log (
  log_id  NUMBER PRIMARY KEY,
  payload VARCHAR2(400) CONSTRAINT ck_api_log_json CHECK (payload IS JSON)
);
OUTPUT
Table created.
Reproducerun as lab_a
INSERT INTO api_log VALUES (1, '{"order_id": 100, "status": "PAID"');
✕ ERROR
INSERT INTO api_log VALUES (1, '{"order_id": 100, "status": "PAID"')
*
ERROR at line 1:
ORA-02290: check constraint (LAB_A.CK_API_LOG_JSON) violated
Help: https://docs.oracle.com/error-help/db/ora-02290/
Check the causerun as lab_a
COLUMN constraint_name FORMAT A16
COLUMN condition FORMAT A16
SELECT constraint_name, CAST(search_condition_vc AS VARCHAR2(16)) AS condition FROM user_constraints WHERE table_name = 'API_LOG' AND constraint_type = 'C';
SELECT CASE WHEN '{"order_id": 100, "status": "PAID"' IS JSON THEN 'VALID' ELSE 'INVALID' END AS json_check FROM dual;
OUTPUT
CONSTRAINT_NAME  CONDITION
---------------- ----------------
CK_API_LOG_JSON  payload IS JSON

1 row selected.


JSON_CH
-------
INVALID

1 row selected.

The condition of CK_API_LOG_JSON is payload IS JSON, and the inserted string itself is INVALID.

Checkrun as lab_a
SELECT CASE WHEN '{"order_id": 100, "status": "PAID"}' IS JSON THEN 'VALID' ELSE 'INVALID' END AS json_check FROM dual;
OUTPUT
JSON_CH
-------
VALID

1 row selected.

Test the string with CASE WHEN ... IS JSON THEN ... first. Cut-off or hand-built JSON is the usual cause.

After the fixrun as lab_a
INSERT INTO api_log VALUES (1, '{"order_id": 100, "status": "PAID"}');
SELECT log_id, JSON_VALUE(payload, '$.status') AS status FROM api_log;
✓ SUCCESS
1 row created.


    LOG_ID STATUS
---------- ------------------------------
         1 PAID

1 row selected.

07A new status value was added in the app, but not to the CHECK list

orders.status has CHECK (status IN ('NEW', 'PAID', 'SHIPPED')). When a cancel feature started saving CANCELED, UPDATE orders SET status = 'CANCELED' WHERE order_id = 1; failed with ORA-02290. The value is spelled correctly; it is simply not in the list.

Oracle has no command to edit a CHECK condition in place. Drop the constraint and add it again with the new value under the same name. After that the same UPDATE changed 1 row to CANCELED.

Setup
Setuprun as lab_a
CREATE TABLE orders (
  order_id NUMBER PRIMARY KEY,
  status   VARCHAR2(10) CONSTRAINT ck_orders_status CHECK (status IN ('NEW', 'PAID', 'SHIPPED'))
);
INSERT INTO orders VALUES (1, 'PAID');
COMMIT;
OUTPUT
Table created.


1 row created.


Commit complete.
Reproducerun as lab_a
UPDATE orders SET status = 'CANCELED' WHERE order_id = 1;
✕ ERROR
UPDATE orders SET status = 'CANCELED' WHERE order_id = 1
*
ERROR at line 1:
ORA-02290: check constraint (LAB_A.CK_ORDERS_STATUS) violated
Help: https://docs.oracle.com/error-help/db/ora-02290/
Check the causerun as lab_a
COLUMN constraint_name FORMAT A16
COLUMN condition FORMAT A40
SELECT constraint_name, CAST(search_condition_vc AS VARCHAR2(40)) AS condition FROM user_constraints WHERE table_name = 'ORDERS' AND constraint_type = 'C';
OUTPUT
CONSTRAINT_NAME  CONDITION
---------------- ----------------------------------------
CK_ORDERS_STATUS status IN ('NEW', 'PAID', 'SHIPPED')

1 row selected.

The condition is status IN ('NEW', 'PAID', 'SHIPPED'). CANCELED is not in it, so the list itself has to change, not the data.

Fixrun as lab_a
ALTER TABLE orders DROP CONSTRAINT ck_orders_status;
ALTER TABLE orders ADD CONSTRAINT ck_orders_status
  CHECK (status IN ('NEW', 'PAID', 'SHIPPED', 'CANCELED'));
OUTPUT
Table altered.


Table altered.

Drop and add in one go, and keep the same constraint name so later error messages still show CK_ORDERS_STATUS.

After the fixrun as lab_a
UPDATE orders SET status = 'CANCELED' WHERE order_id = 1;
SELECT order_id, status FROM orders;
✓ SUCCESS
1 row updated.


  ORDER_ID STATUS
---------- ------------------------------
         1 CANCELED

1 row selected.

FAQ

What does ORA-02290 check constraint violated mean?

The row you are inserting or updating fails a CHECK condition on the table. The constraint name is in the message, for example LAB_A.CK_ORDERS_STATUS.

How do I see the condition of a check constraint in Oracle?

Query USER_CONSTRAINTS by the name from the message: SELECT search_condition_vc FROM user_constraints WHERE constraint_name = 'CK_ORDERS_STATUS';.

Why do I get ORA-02290 when the value looks correct?

Check upper/lower case and spaces. In the lab 'new' failed while 'NEW' passed, because string comparison is case-sensitive.

Does ORA-02290 roll back the whole UPDATE?

The failing statement is undone as a whole. In the lab one row would have gone negative, and no rows were changed by that UPDATE.

ORA-02290 shows SYS_C00xxxx. How do I find which check it is?

Query by table: SELECT constraint_name, search_condition_vc FROM user_constraints WHERE table_name = 'PAYMENTS' AND constraint_type = 'C'; In the lab SYS_C0011638 was amount > 0.

How do I find which row causes ORA-02290 in INSERT ... SELECT?

Query the source with the opposite of the condition, for example WHERE status NOT IN ('NEW', 'PAID', 'SHIPPED'). In the lab it found paid and SHIPPED (trailing space).

How do I modify a check constraint in Oracle to allow a new value?

There is no command to change the condition in place. Run ALTER TABLE orders DROP CONSTRAINT ck_orders_status; and then ALTER TABLE orders ADD CONSTRAINT ck_orders_status CHECK (status IN ('NEW', 'PAID', 'SHIPPED', 'CANCELED'));. In the lab the UPDATE to CANCELED then succeeded.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0