Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-26 · container image gvenzl/oracle-free:23-slim
Oracle raises ORA-00957 when one statement defines the same column name twice. The asterisk in SQL*Plus points at the second one.
Below are three common cases reproduced on a real database, with the fix we ran and its result.
01A join view selects columns with the same name from two tables
emp and dept both have a NAME column. CREATE VIEW emp_dept_v AS SELECT e.emp_id, e.name, d.dept_id, d.name FROM emp e JOIN dept d ... failed with ORA-00957. A plain SELECT with the same join runs fine, but a view needs a unique name for every column.
user_tab_columns showed that NAME and DEPT_ID exist in both tables. We gave the two name columns aliases (e.name AS emp_name, d.name AS dept_name). The view was created and returned EMP_NAME and DEPT_NAME columns.
Setup
CREATE TABLE dept (dept_id NUMBER PRIMARY KEY, name VARCHAR2(20));
CREATE TABLE emp (emp_id NUMBER PRIMARY KEY, name VARCHAR2(20), dept_id NUMBER REFERENCES dept);
INSERT INTO dept VALUES (10, 'SALES');
INSERT INTO dept VALUES (20, 'IT');
INSERT INTO emp VALUES (1, 'KIM', 10);
INSERT INTO emp VALUES (2, 'LEE', 20);
COMMIT;Table created.
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
Commit complete.CREATE VIEW emp_dept_v AS SELECT e.emp_id, e.name, d.dept_id, d.name FROM emp e JOIN dept d ON e.dept_id = d.dept_id;CREATE VIEW emp_dept_v AS SELECT e.emp_id, e.name, d.dept_id, d.name FROM emp e JOIN dept d ON e.dept_id = d.dept_id
*
ERROR at line 1:
ORA-00957: duplicate column name
Help: https://docs.oracle.com/error-help/db/ora-00957/COLUMN table_name FORMAT A6
COLUMN column_name FORMAT A8
SELECT table_name, column_name FROM user_tab_columns WHERE table_name IN ('EMP', 'DEPT') AND column_name IN ('NAME', 'DEPT_ID') ORDER BY column_name, table_name;TABLE_ COLUMN_N
------ --------
DEPT DEPT_ID
EMP DEPT_ID
DEPT NAME
EMP NAME
4 rows selected.The same applies to CREATE TABLE ... AS SELECT and inline views: alias every column whose name repeats.
CREATE VIEW emp_dept_v AS SELECT e.emp_id, e.name AS emp_name, d.dept_id, d.name AS dept_name FROM emp e JOIN dept d ON e.dept_id = d.dept_id;
SELECT * FROM emp_dept_v ORDER BY emp_id;View created.
EMP_ID EMP_NAME DEPT_ID DEPT_NAME
---------- -------------------- ---------- --------------------
1 KIM 10 SALES
2 LEE 20 IT
2 rows selected.02The same column is listed twice in INSERT
INSERT INTO orders (order_id, cust_id, amount, cust_id) VALUES (1, 100, 5000, 'NEW') failed with ORA-00957. The fourth column should have been status, but cust_id was typed again.
Comparing the list with user_tab_columns (ORDER_ID, CUST_ID, AMOUNT, STATUS) showed the mistake. After changing the last column to status, the row was inserted.
Setup
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, cust_id NUMBER, amount NUMBER, status VARCHAR2(10));Table created.INSERT INTO orders (order_id, cust_id, amount, cust_id) VALUES (1, 100, 5000, 'NEW');INSERT INTO orders (order_id, cust_id, amount, cust_id) VALUES (1, 100, 5000, 'NEW')
*
ERROR at line 1:
ORA-00957: duplicate column name
Help: https://docs.oracle.com/error-help/db/ora-00957/COLUMN column_name FORMAT A10
SELECT column_id, column_name FROM user_tab_columns WHERE table_name = 'ORDERS' ORDER BY column_id; COLUMN_ID COLUMN_NAM
---------- ----------
1 ORDER_ID
2 CUST_ID
3 AMOUNT
4 STATUS
4 rows selected.This often happens when a long column list is copied and edited by hand. Check the list against the table's columns in order.
INSERT INTO orders (order_id, cust_id, amount, status) VALUES (1, 100, 5000, 'NEW');
SELECT * FROM orders;
ROLLBACK;1 row created.
ORDER_ID CUST_ID AMOUNT STATUS
---------- ---------- ---------- ------------------------------
1 100 5000 NEW
1 row selected.
Rollback complete.03CREATE TABLE defines the same column twice
A CREATE TABLE board (...) with created_at DATE on line 3 and again on line 6 failed with ERROR at line 6: ORA-00957. The line number points at the second definition.
The failed statement did not leave a table behind: user_tables returned BOARD_TABLES 0. So we just renamed the second column to updated_at and ran CREATE TABLE again. It succeeded.
CREATE TABLE board (
board_id NUMBER PRIMARY KEY,
title VARCHAR2(100),
created_at DATE,
writer VARCHAR2(30),
created_at DATE
); created_at DATE
*
ERROR at line 6:
ORA-00957: duplicate column name
Help: https://docs.oracle.com/error-help/db/ora-00957/SELECT COUNT(*) AS board_tables FROM user_tables WHERE table_name = 'BOARD';BOARD_TABLES
------------
0
1 row selected.CREATE TABLE board (
board_id NUMBER PRIMARY KEY,
title VARCHAR2(100),
created_at DATE,
writer VARCHAR2(30),
updated_at DATE
);Table created.FAQ
What does ORA-00957 duplicate column name mean?
One statement defines the same column name twice: in a view's select list, an INSERT column list, or a CREATE TABLE.
Why does my join query work but CREATE VIEW fails with ORA-00957?
A query can return two columns with the same name, but a view cannot. Give the repeated columns aliases, such as e.name AS emp_name.
How do I find which column is duplicated?
Look at the asterisk and the line number in the error output. They point at the second occurrence of the name.
Does a failed CREATE TABLE leave a table behind?
No. In our test user_tables had no row for the table, so you can fix the column and run the same CREATE TABLE again.
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