How do I find the which table it is belong when I'm only given column name?

StackOverflow https://stackoverflow.com/questions/17159633

  •  01-06-2022
  •  | 
  •  

Domanda

Hi I am working on SQL query, a total novice.

So I only have column name, and trying to find which table it is belong to.

How do I find that in toad? Can someone help?

È stato utile?

Soluzione

Most databases have tables that describe the contents of the databases. If you are using toad, then I might surmise that you are using Oracle.

If so, you can use:

select *
from syscolumns
where columnname = <whatever you are looking for>

And then lookup the referenceid in systables.

In many other databases, you can use:

select *
from INFORMATION_SCHEMA.columns
where column_name = <whatever you are looking for>

Altri suggerimenti

Something like this should work, it will return the column name you search and the associated table

SELECT c.name as columnname, t.name as tablename from sys.columns c 
join sys.tables t on c.object_id = T.object_id
where c.name =' put the column you want to find here'
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top