1

I want to retrieve column names from a table through a db link but I'm not able to do it...

Although this query is working

SELECT *
FROM myTableName@myDbLink;

the following one is not:

SELECT column_name
FROM all_tab_columns@myDbLink
WHERE table_name = 'myTableName'

What's the correct way of retrieving the column names?

1 Answer 1

4

CaSE mATterS.

In Oracle, table names are - by default - in UPPERCASE, so - try with

SELECT column_name
FROM all_tab_columns@myDbLink
WHERE table_name = 'MYTABLENAME'
Sign up to request clarification or add additional context in comments.

4 Comments

if myTableName in the select works, why should 'MYTABLENAME' works?
@JaviOverflow : Please read stackoverflow.com/questions/7425153/…
That's really interesting! I didn't know that. However, when I use "myTableName" in my select query, it's still working, so I guess I'm using the same-case-sensitive name.
Mixed case is evil, avoid creating Oracle objects using mixed case. If you want to do that, you'll have to use double quotes. And if you do that, you'll have to use double quotes everywhere, always, whenever you reference that object, and never fail letter case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.