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-00947 means the right side gives fewer values than the left side asks for. In an INSERT the left side is the target columns: every column of the table without a column list, or the listed columns with one. The same check applies to UPDATE ... SET (a, b) = (SELECT ...) and to (a, b) IN (SELECT ...).

Count the columns on both sides. In the lab the causes were a column added to the table later, a column list longer than VALUES, INSERT ... SELECT * from a table with fewer columns, a MERGE insert branch without a column list, a SELECT INTO missing a variable, a two-column UPDATE fed by a one-column subquery, and a two-column IN compared with a one-column subquery.

01A column was added to the table, and the INSERT has no column list

The table started with 2 columns, then ALTER TABLE orders ADD (status VARCHAR2(10)); added a third. INSERT INTO orders VALUES (1, 'Kim'); then failed with ORA-00947, because without a column list Oracle expects a value for all 3 columns (ORDER_ID, CUST_NAME, STATUS).

Writing the column list, INSERT INTO orders (order_id, cust_name) VALUES (1, 'Kim');, inserted the row. STATUS was left empty (NULL).

Setup
Setuprun as lab_a
CREATE TABLE orders (order_id NUMBER, cust_name VARCHAR2(20));
ALTER TABLE orders ADD (status VARCHAR2(10));
OUTPUT
Table created.


Table altered.
Reproducerun as lab_a
INSERT INTO orders VALUES (1, 'Kim');
✕ ERROR
INSERT INTO orders VALUES (1, 'Kim')
            *
ERROR at line 1:
ORA-00947: not enough values
Help: https://docs.oracle.com/error-help/db/ora-00947/
Check the causerun as lab_a
SELECT column_name FROM user_tab_columns WHERE table_name = 'ORDERS' ORDER BY column_id;
OUTPUT
COLUMN_NAME
------------------------------
ORDER_ID
CUST_NAME
STATUS

3 rows selected.

Always write the column list in INSERT. Then adding a column to the table does not break existing code.

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


  ORDER_ID CUST_NAME            STATUS
---------- -------------------- ------------------------------
         1 Kim

1 row selected.

02The column list has more columns than VALUES

INSERT INTO orders (order_id, cust_name, status) VALUES (1, 'Kim'); lists 3 columns but gives only 2 values, so it failed with ORA-00947.

Adding the missing value, VALUES (1, 'Kim', 'NEW'), inserted the row 1 Kim NEW.

Setup
Setuprun as lab_a
CREATE TABLE orders (order_id NUMBER, cust_name VARCHAR2(20), status VARCHAR2(10));
OUTPUT
Table created.
Reproducerun as lab_a
INSERT INTO orders (order_id, cust_name, status) VALUES (1, 'Kim');
✕ ERROR
INSERT INTO orders (order_id, cust_name, status) VALUES (1, 'Kim')
                                                 *
ERROR at line 1:
ORA-00947: not enough values
Help: https://docs.oracle.com/error-help/db/ora-00947/
Check the causerun as lab_a
SELECT column_name FROM user_tab_columns WHERE table_name = 'ORDERS' ORDER BY column_id;
OUTPUT
COLUMN_NAME
------------------------------
ORDER_ID
CUST_NAME
STATUS

3 rows selected.

Either add the missing value or remove that column from the list.

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


  ORDER_ID CUST_NAME            STATUS
---------- -------------------- ------------------------------
         1 Kim                  NEW

1 row selected.

03INSERT ... SELECT * returns fewer columns than the target table

INSERT INTO orders SELECT * FROM orders_stage; failed. Counting the columns showed ORDERS has 3 and ORDERS_STAGE has 2.

Naming the columns on both sides and filling the third with a constant, INSERT INTO orders (order_id, cust_name, status) SELECT order_id, cust_name, 'NEW' FROM orders_stage;, created 2 rows.

Setup
Setuprun as lab_a
CREATE TABLE orders (order_id NUMBER, cust_name VARCHAR2(20), status VARCHAR2(10));
CREATE TABLE orders_stage (order_id NUMBER, cust_name VARCHAR2(20));
INSERT INTO orders_stage VALUES (10, 'Lee');
INSERT INTO orders_stage VALUES (11, 'Park');
COMMIT;
OUTPUT
Table created.


Table created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
INSERT INTO orders SELECT * FROM orders_stage;
✕ ERROR
INSERT INTO orders SELECT * FROM orders_stage
            *
ERROR at line 1:
ORA-00947: not enough values
Help: https://docs.oracle.com/error-help/db/ora-00947/
Check the causerun as lab_a
SELECT table_name, COUNT(*) AS cols FROM user_tab_columns WHERE table_name IN ('ORDERS', 'ORDERS_STAGE') GROUP BY table_name ORDER BY table_name;
OUTPUT
TABLE_NAME                           COLS
------------------------------ ----------
ORDERS                                  3
ORDERS_STAGE                            2

2 rows selected.

Avoid SELECT * in INSERT ... SELECT. List the columns so the count and order match.

Fix: run the corrected statementrun as lab_a
INSERT INTO orders (order_id, cust_name, status)
SELECT order_id, cust_name, 'NEW' FROM orders_stage;
SELECT order_id, cust_name, status FROM orders ORDER BY order_id;
✓ SUCCESS
2 rows created.


  ORDER_ID CUST_NAME            STATUS
---------- -------------------- ------------------------------
        10 Lee                  NEW
        11 Park                 NEW

2 rows selected.

04MERGE WHEN NOT MATCHED THEN INSERT VALUES without a column list

ALTER TABLE emp ADD (updated_at DATE); added a fourth column to the target table. The MERGE then failed with ORA-00947 because its insert branch was INSERT VALUES (s.emp_id, s.name, s.dept_id): with no column list, Oracle expects a value for every column of EMP, and there are only three.

The error points at line 1 (MERGE INTO emp e), not at the INSERT line, so the cause is easy to miss in a long MERGE. Adding the column list INSERT (emp_id, name, dept_id) VALUES (...) made it work: 2 rows merged., and UPDATED_AT stayed empty.

Setup
Setuprun as lab_a
CREATE TABLE emp (emp_id NUMBER PRIMARY KEY, name VARCHAR2(20), dept_id NUMBER);
CREATE TABLE emp_stage (emp_id NUMBER, name VARCHAR2(20), dept_id NUMBER);
INSERT INTO emp VALUES (1, 'KIM', 10);
INSERT INTO emp_stage VALUES (1, 'KIM', 20);
INSERT INTO emp_stage VALUES (2, 'LEE', 30);
COMMIT;
ALTER TABLE emp ADD (updated_at DATE);
OUTPUT
Table created.


Table created.


1 row created.


1 row created.


1 row created.


Commit complete.


Table altered.
Reproducerun as lab_a
MERGE INTO emp e
USING emp_stage s
   ON (e.emp_id = s.emp_id)
 WHEN MATCHED THEN
   UPDATE SET e.name = s.name, e.dept_id = s.dept_id
 WHEN NOT MATCHED THEN
   INSERT VALUES (s.emp_id, s.name, s.dept_id);
✕ ERROR
MERGE INTO emp e
           *
ERROR at line 1:
ORA-00947: not enough values
Help: https://docs.oracle.com/error-help/db/ora-00947/
Check the causerun as lab_a
SELECT table_name, COUNT(*) AS column_count
  FROM user_tab_columns
 WHERE table_name IN ('EMP', 'EMP_STAGE')
 GROUP BY table_name
 ORDER BY table_name;
OUTPUT
TABLE_NAME                     COLUMN_COUNT
------------------------------ ------------
EMP                                       4
EMP_STAGE                                 3

2 rows selected.

EMP (the target) has 4 columns while EMP_STAGE (the source) has 3. The three values in INSERT VALUES are one short.

Checkrun as lab_a
SELECT column_name FROM user_tab_columns WHERE table_name = 'EMP' ORDER BY column_id;
OUTPUT
COLUMN_NAME
------------------------------
EMP_ID
NAME
DEPT_ID
UPDATED_AT

4 rows selected.

Always write the column list in the MERGE insert branch too, so adding a column to the target does not break the batch.

After the fixrun as lab_a
MERGE INTO emp e
USING emp_stage s
   ON (e.emp_id = s.emp_id)
 WHEN MATCHED THEN
   UPDATE SET e.name = s.name, e.dept_id = s.dept_id
 WHEN NOT MATCHED THEN
   INSERT (emp_id, name, dept_id) VALUES (s.emp_id, s.name, s.dept_id);
COMMIT;
SELECT emp_id, name, dept_id, updated_at FROM emp ORDER BY emp_id;
✓ SUCCESS
2 rows merged.


Commit complete.


    EMP_ID NAME                              DEPT_ID UPDATED_AT
---------- ------------------------------ ---------- ------------------
         1 KIM                                    20
         2 LEE                                    30

2 rows selected.

05PL/SQL SELECT INTO has fewer variables than selected columns

SELECT name, sal INTO v_name FROM emp selects two columns but gives only one variable. Inside PL/SQL the error is wrapped: ORA-06550 with the position, then PL/SQL: ORA-00947: not enough values.

Add a variable for every selected column. With INTO v_name, v_sal the block printed KIM 500.

Setup
Setuprun as lab_a
CREATE TABLE emp (emp_id NUMBER PRIMARY KEY, name VARCHAR2(10), sal NUMBER);
INSERT INTO emp VALUES (1, 'KIM', 500);
COMMIT;
OUTPUT
Table created.


1 row created.


Commit complete.
Reproducerun as lab_a
SET SERVEROUTPUT ON
DECLARE
  v_name emp.name%TYPE;
BEGIN
  SELECT name, sal INTO v_name FROM emp WHERE emp_id = 1;
  DBMS_OUTPUT.PUT_LINE(v_name);
END;
/
✕ ERROR
  SELECT name, sal INTO v_name FROM emp WHERE emp_id = 1;
                               *
ERROR at line 4:
ORA-06550: line 4, column 32:
PL/SQL: ORA-00947: not enough values
ORA-06550: line 4, column 3:
PL/SQL: SQL Statement ignored
Help: https://docs.oracle.com/error-help/db/ora-06550/
Check the causerun as lab_a
SELECT name, sal FROM emp WHERE emp_id = 1;
OUTPUT
NAME                                  SAL
------------------------------ ----------
KIM                                   500

1 row selected.
Fix: run the corrected statementrun as lab_a
SET SERVEROUTPUT ON
DECLARE
  v_name emp.name%TYPE;
  v_sal  emp.sal%TYPE;
BEGIN
  SELECT name, sal INTO v_name, v_sal FROM emp WHERE emp_id = 1;
  DBMS_OUTPUT.PUT_LINE(v_name || ' ' || v_sal);
END;
/
✓ SUCCESS
KIM 500

PL/SQL procedure successfully completed.

06UPDATE SET (a, b) = (SELECT ...) returns only one column

The goal was to copy the new salary and grade from sal_change into emp in one UPDATE. SET (sal, grade) = (SELECT c.new_sal FROM sal_change c ...) failed with ORA-00947 at line 2: two columns on the left, one column in the subquery.

After selecting both columns, SELECT c.new_sal, c.new_grade, the UPDATE changed 1 row and employee 1 became 350 G2. Employee 2 was left alone because of the WHERE e.emp_id IN (...) filter.

Setup
Setuprun as lab_a
CREATE TABLE emp (emp_id NUMBER PRIMARY KEY, sal NUMBER, grade VARCHAR2(5));
CREATE TABLE sal_change (emp_id NUMBER PRIMARY KEY, new_sal NUMBER, new_grade VARCHAR2(5));
INSERT INTO emp VALUES (1, 300, 'G1');
INSERT INTO emp VALUES (2, 400, 'G2');
INSERT INTO sal_change VALUES (1, 350, 'G2');
COMMIT;
OUTPUT
Table created.


Table created.


1 row created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
UPDATE emp e
   SET (sal, grade) = (SELECT c.new_sal FROM sal_change c WHERE c.emp_id = e.emp_id)
 WHERE e.emp_id IN (SELECT emp_id FROM sal_change);
✕ ERROR
   SET (sal, grade) = (SELECT c.new_sal FROM sal_change c WHERE c.emp_id = e.emp_id)
                       *
ERROR at line 2:
ORA-00947: not enough values
Help: https://docs.oracle.com/error-help/db/ora-00947/
Check the causerun as lab_a
SELECT emp_id, new_sal, new_grade FROM sal_change;
OUTPUT
    EMP_ID    NEW_SAL NEW_G
---------- ---------- -----
         1        350 G2

1 row selected.

Put exactly as many columns in the subquery as in the SET ( ... ) list, in the same order.

Fix: run the corrected statementrun as lab_a
UPDATE emp e
   SET (sal, grade) = (SELECT c.new_sal, c.new_grade FROM sal_change c WHERE c.emp_id = e.emp_id)
 WHERE e.emp_id IN (SELECT emp_id FROM sal_change);
SELECT emp_id, sal, grade FROM emp ORDER BY emp_id;
✓ SUCCESS
1 row updated.


    EMP_ID        SAL GRADE
---------- ---------- -----
         1        350 G2
         2        400 G2

2 rows selected.

07(a, b) IN / NOT IN subquery returns only one column

To find order lines not shipped yet, the query compared a composite key: WHERE (order_id, line_no) NOT IN (SELECT order_id FROM shipped_lines). It failed with ORA-00947 at line 3, pointing at the subquery. Two columns on the left need two columns in the subquery.

With SELECT order_id, line_no FROM shipped_lines the query returned the two unshipped lines, 100 2 and 101 1.

Setup
Setuprun as lab_a
CREATE TABLE order_lines (order_id NUMBER, line_no NUMBER, qty NUMBER, PRIMARY KEY (order_id, line_no));
CREATE TABLE shipped_lines (order_id NUMBER, line_no NUMBER);
INSERT INTO order_lines VALUES (100, 1, 5);
INSERT INTO order_lines VALUES (100, 2, 3);
INSERT INTO order_lines VALUES (101, 1, 7);
INSERT INTO shipped_lines VALUES (100, 1);
COMMIT;
OUTPUT
Table created.


Table created.


1 row created.


1 row created.


1 row created.


1 row created.


Commit complete.
Reproducerun as lab_a
SELECT order_id, line_no, qty
  FROM order_lines
 WHERE (order_id, line_no) NOT IN (SELECT order_id FROM shipped_lines);
✕ ERROR
 WHERE (order_id, line_no) NOT IN (SELECT order_id FROM shipped_lines)
                                   *
ERROR at line 3:
ORA-00947: not enough values
Help: https://docs.oracle.com/error-help/db/ora-00947/
Check the causerun as lab_a
SELECT order_id, line_no FROM shipped_lines;
OUTPUT
  ORDER_ID    LINE_NO
---------- ----------
       100          1

1 row selected.

For composite keys, list every key column in the subquery in the same order as the left side.

Fix: run the corrected statementrun as lab_a
SELECT order_id, line_no, qty
  FROM order_lines
 WHERE (order_id, line_no) NOT IN (SELECT order_id, line_no FROM shipped_lines)
 ORDER BY order_id, line_no;
✓ SUCCESS
  ORDER_ID    LINE_NO        QTY
---------- ---------- ----------
       100          2          3
       101          1          7

2 rows selected.

FAQ

What does ORA-00947 not enough values mean?

The INSERT has fewer values than target columns. Without a column list, every column of the table needs a value.

Why does an INSERT that used to work now fail with ORA-00947?

A column was probably added to the table. An INSERT without a column list now needs one more value. Add the column list to the INSERT.

How do I fix ORA-00947 in INSERT INTO ... SELECT?

The SELECT returns fewer columns than the table has. Write the target columns explicitly, and add a constant or NULL for any column the source does not have.

Why does MERGE fail with ORA-00947 after adding a column?

The WHEN NOT MATCHED THEN INSERT branch has no column list, so it needs a value for every column of the target table. Write INSERT (col1, col2, ...) VALUES (...). The error position points at the first line of the MERGE, not at the INSERT.

What is the difference between ORA-00947 and ORA-00913?

ORA-00947 means too few values, ORA-00913 means too many. Both are fixed by making the column count and the value count the same.

Why do I get PL/SQL: ORA-00947 in SELECT INTO?

The SELECT list has more columns than the INTO list has variables. Count both lists and add the missing variable (or a record with %ROWTYPE).

Why do I get ORA-00947 in UPDATE SET (col1, col2) = (SELECT ...)?

The subquery returns fewer columns than the SET ( ... ) list. In the lab SET (sal, grade) = (SELECT c.new_sal ...) failed, and SELECT c.new_sal, c.new_grade fixed it.

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