# OCIError: ORA-00918: column ambiguously defined

**URL:** <https://www.ruby-forum.com/t/ocierror-ora-00918-column-ambiguously-defined/97042>\
**Category:** Rails\
**Created:** [July 4, 2006, 1:09pm UTC](https://www.ruby-forum.com/t/ocierror-ora-00918-column-ambiguously-defined/97042 "2006-07-04T13:09:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 4, 2006, 1:09pm UTC](https://www.ruby-forum.com/t/ocierror-ora-00918-column-ambiguously-defined/97042/1 "2006-07-04T13:09:42Z")

</div>

Hi all,  
when I execute the command “rake db:schema:dump” i get this error in the  
db/schema.rb file.

* * *

# Could not dump table “region” because of following

ActiveRecord::StatementInvalid

# OCIError: ORA-00918: column ambiguously defined:

SELECT lower(i.index\_name) as index\_name, i.uniqueness, lowe  
r(c.column\_name) as column\_name  
FROM user\_indexes i, user\_ind\_columns c  
WHERE i.table\_name = ‘REGION’  
AND c.index\_name = i.index\_name  
AND i.index\_name NOT IN (SELECT index\_name FROM  
user\_constraints WHERE constraint\_type = ‘P’)  
ORDER BY i.index\_name, c.column\_position

* * *

I have the same error message in the db/schema.rb file for all the  
database tables (OCIError: ORA-00918: column ambiguously defined).

could you help me please ? thanks

---

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 4, 2006, 1:36pm UTC](https://www.ruby-forum.com/t/ocierror-ora-00918-column-ambiguously-defined/97042/2 "2006-07-04T13:36:20Z")

</div>

The Allnighter wrote:

> Hi all,  
> when I execute the command “rake db:schema:dump” i get this error in the  
> db/schema.rb file.
> 
> * * *
> 
> # Could not dump table “region” because of following
> 
> ActiveRecord::StatementInvalid
> 
> # OCIError: ORA-00918: column ambiguously defined:
> 
> SELECT lower(i.index\_name) as index\_name, i.uniqueness, lowe  
> r(c.column\_name) as column\_name  
> FROM user\_indexes i, user\_ind\_columns c  
> WHERE i.table\_name = ‘REGION’  
> AND c.index\_name = i.index\_name  
> AND i.index\_name NOT IN (SELECT index\_name FROM  
> user\_constraints WHERE constraint\_type = ‘P’)  
> ORDER BY i.index\_name, c.column\_position
> 
> * * *
> 
> I have the same error message in the db/schema.rb file for all the  
> database tables (OCIError: ORA-00918: column ambiguously defined).
> 
> could you help me please ? thanks

change the sql from  
SELECT lower(i.index\_name) as index\_name, i.uniqueness, lowe  
r(c.column\_name) as column\_name  
FROM user\_indexes i, user\_ind\_columns c  
WHERE i.table\_name = ‘REGION’  
AND c.index\_name = i.index\_name  
AND i.index\_name NOT IN (SELECT index\_name FROM  
user\_constraints WHERE constraint\_type = ‘P’)  
ORDER BY i.index\_name, c.column\_position  
to  
SELECT lower(i.index\_name) as index\_name, i.uniqueness, lowe  
r(c.column\_name) as column\_name  
FROM user\_indexes i, user\_ind\_columns c  
WHERE i.table\_name = ‘REGION’  
AND c.index\_name = i.index\_name  
AND i.index\_name NOT IN (SELECT uc.index\_name FROM  
user\_constraints uc WHERE uc.constraint\_type = ‘P’)  
ORDER BY i.index\_name, c.column\_position

---

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 4, 2006, 4:05pm UTC](https://www.ruby-forum.com/t/ocierror-ora-00918-column-ambiguously-defined/97042/3 "2006-07-04T16:05:30Z")

</div>

> change the sql from  
> SELECT lower(i.index\_name) as index\_name, i.uniqueness, lowe  
> r(c.column\_name) as column\_name  
> FROM user\_indexes i, user\_ind\_columns c  
> WHERE i.table\_name = ‘REGION’  
> AND c.index\_name = i.index\_name  
> AND i.index\_name NOT IN (SELECT index\_name FROM  
> user\_constraints WHERE constraint\_type = ‘P’)  
> ORDER BY i.index\_name, c.column\_position  
> to  
> SELECT lower(i.index\_name) as index\_name, i.uniqueness, lowe  
> r(c.column\_name) as column\_name  
> FROM user\_indexes i, user\_ind\_columns c  
> WHERE i.table\_name = ‘REGION’  
> AND c.index\_name = i.index\_name  
> AND i.index\_name NOT IN (SELECT uc.index\_name FROM  
> user\_constraints uc WHERE uc.constraint\_type = ‘P’)  
> ORDER BY i.index\_name, c.column\_position  
> thanks for the reply.  
> i’ve tried to execute this query with ScratchPad (Oracle Enterprise  
> Manager), but i get the error : ORA-00904 : Invalid Column Name  
> even if I get this query working, how can i tell rake to modify this  
> generated request ?

---

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 10, 2006, 7:01am UTC](https://www.ruby-forum.com/t/ocierror-ora-00918-column-ambiguously-defined/97042/4 "2006-07-10T07:01:02Z")

</div>

The A. wrote:

> even if I get this query working, how can i tell rake to modify this  
> generated request ?

The original query works fine in the versions of Oracle I’ve tested.  
What version are you running?
