Search notes:

ORA-00957: duplicate column name

CREATE TABLE statement

A table column name must uniquely identify a column and must therefore not be used multiple times.
The following create table statement fails because col_two is specified twice:
create table tq84_ora_00957 (
   col_one   number  (1),
   col_two   varchar2(2),
   col_two   varchar2(2),
   col_three date
);

INSERT statement

Similarly, in an insert statement, a column name must also be unique.
create table tq84_ora_00957 (
   col_one   number  (1),
   col_two   varchar2(2),  -- col_two appears twice
   col_three date
);

insert into tq84_ora_00957 (
   col_one,
   col_two,
   col_two,
   col_three
)
values (
   1,
  'X',
  'X',
   sysdate
);

SELECT statement

It is permissible to select the same column (name) twice in a select statement:
select
   col_one,
   col_two,
   col_two,    -- col_two appears twice
   col_three
from
   tq84_ora_00957;
In this case, Oracle quietly aliases the second col_two to col_two_1.

Views

Although the select statement above can be executed, it cannot be used in a view.
The following statement also throws a ORA-00957: duplicate column name error:
create view tq84_ora_00957_v as
select
   col_one,
   col_two,
   col_two,
   col_three
from
   tq84_ora_00957;

MODEL clause

The ORA-00957 error can also be thrown in the model clause:
select
   *
from
   dual
model
   dimension by (dummy)
   measures     (dummy)
   ()
;

See also

ORA-00918: column ambiguously defined
Other Oracle error messages

Index