sql - Inserting into too many columns via SELECT query -


While it works as expected:

 SQL & gt; Drop Table Test 1; Table Dropped SQL & gt; Create table test (COL1 INTEGER, COL2 INTEGER); The table was created in SQL & gt; INSERT when 1 = 1 2 then test 1 (COL1, COL2) with 3 SELECT 1, 0 dual; 1 row created sql & gt;  

I get a strange "ORA-00918: Column fuzzy defined" error, which attempts to do it with more than two columns:

 SQL & gt; ; Drop Table Test 1; Table Dropped SQL & gt; Create a Table Test (COL1 INTEGER, COL2 Intecher, COL3 Integer); The table was created in SQL & gt; INSERT when 1 = 1 2 again in test1 (COL1, COL2, COL3) 3 SELECT 1, 0, 0 by DUAL; Then in Test 1 (COL1, COL2, COL3) * Error 2 in line: ORA-00918: Columns ambiguously in SQL & gt;  

Why am getting ORA-00918 error? Is there any limit on how many columns I can select in an insert ... then choose the pattern in ...?

Note: I am using Oracle 11.2.0.1.0, and the actual query I am trying to execute in production is more complex and reference is to use other tables (and "VALUES" Do not be enough) This is just a simplified case ...

Use aliases:

 < Code> SQL & gt; Create a Table Test (COL1 INTEGER, COL2 Intecher, COL3 Integer); The table was created in SQL & gt; INSERT when 1 = 1 2 then select test 1 (COL1, COL2, COL3) 3, select 1 "1", 0 "2", 0 "3" with double; 1 line created   

Due to this you get this obscure column error because when you do not provide a nickname, the oracle will use the rules of each column name in this case else The third column has the same name ( "0" ) and can thus be assigned from external query:

  SQL & gt; Select Dual to 1, 0, 0; 1 0 ---------- ---------- ---------- 1 0   

Oracle 'Semantic See the data value while doing the analysis.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -