Concept:
This error
occurs when you are trying to insert data from table with more columns into
table with less columns. Your sub query output contains more columns and the
table where data is to be inserted is having less columns.
Your Query logic is incorrect.
For Example:
- Create a table A having number of columns are 3.
- Insert any data into table.
- Create a table C having number of columns are 2.
- Try to insert data from table B into table A, you will receive an below error message.
“ORA-00913:
too many values”
SQL> create table a (id number, name varchar2(12),address varchar2(12)); Table created. SQL> insert into a values(1,'tom','India'); 1 row created. SQL> insert into a values(2,'scott','India'); 1 row created. SQL> insert into a values(3,'Tiger','Mumbai'); 1 row created. SQL> commit; Commit complete. SQL> select * from a; ID NAME ADDRESS ---------- --------------------------- ------------ 1 tom India 2 scott India 3 Tiger Mumbai SQL> create table c (id number,name varchar2(12)); Table created. SQL> select * from c; no rows selected SQL> insert into c (select * from a); insert into c (select * from a) * ERROR at line 1: ORA-00913: too many values |
1. Try to use same column range in both subquery as well as in main query.
2. Delete extra columns from source table if not needed(Be careful).
Thanks for reading this post ! Please comment if you like this post ! Click on FOLLOW to get future blog updates !
sssss
ReplyDelete