Finding a TABLE based on a COLUMN NAME...

I need to find all tables that that have a common column name.
Upon searching the Forum, I found this nice nugget:
How to find the table in a schema if I only know a particular column name
The problem is, my USER_TAB_COLUMNS is EMPTY!
If it had worked, then my statement would be:
select * from USER_TAB_COLUMNS
where COLUMN_NAME LIKE '%TEST%'
and OWNER='ME';
I get "no rows selected" (though I know they exist)
if I do:
select * from USER_TAB_COLUMNS
I also get "no rows selected"
Any ideas!
Thanks!
KSL.

The user_xxx data dictionary tables show all of the whatevers that are owned by the logged in user. So, if you are logged in as user1 the user_tab_columns view will only show tables and views owned by user1.
The all_xxx dictionary views show all of the whatevers that the logged in user has access to. so if you are logged in as user1 and user2 gave you selet privileges on tablea, then you would see tablea in all_tab_columns.
The dba_xxx views show all objects in the database, but are generally only available to privileged users.
If you have access to the dba_views, try:
SELECT owner, object_type
FROM dba_objects
WHERE UPPER(object_name) = 'ANL'It is possible that the table and or its columns were created with double quotes so are case sensitve. It may also be a synonym, pointing to one of the tables that you got form your query.
If you are only using all_tab_columns then it is possible that the user you are logged in as does not have privileges on the table anl so would not see it in the view.
A long shot, but are you sure you are in the right database?
John

Similar Messages

  • Find all tables in db with column name of a particular string?

    I'm looking for all tables in a db that have a certain column name. How can I find this?

    John,
    thanks for your answer.
    John Mcginnis wrote:
    The quick search field in the schema browser is doing client-side filtering of the list of objects. This means we can only filter on things that we already have fetched from the database, like the object name. We have no current plans to extend the types of information that can filter on, although it is possible we might add the ability to filter based on a few other types of information that we generally fetch with the object name. However, filtering by column name would require pre-fetching the lists of columns for all tables and as such is not likely to be added to the schema browsers search field.
    I'm sure you guys had a Toad review to understand how things are done there.....so
    My 2 cents are: instead of pre-fetching the columns of all tables why don't you add a button below the table drop-down list which should fetch the tables based on the filter columns condition - exactly like Toad.
    Thanks,
    Dani

  • Is it possible to find the  table based on the Date ?

    Dear Team ,
    Is it possible to find the table based on the Date ?
    I have created an table ,But forgot the Table Name .
    Is it possible to find the Tables created on particular Date .
    Regards ,
    Augustine

    as date is record the time also below query will work.
    select * from user_objects
    where
    object_type = 'TABLE' and
    to_date(created,'DD-MON-YYYY') =to_date('<your date value in DD-MON-YYYY format>','DD-MON-YYYY');
    Edited by: shaileshM on Feb 24, 2010 9:39 PM

  • Trying to use ALL_TAB_COLS  to find two tables based on input rows

    I'm using 9i.
    I'm trying to use the ALL_TAB_COLS table to find two tables that contain columns I can join them on. I know the names of the two tables. We can call them table1 and table2. I just using the columns that are stored in them below to find a common set of tables.
    The query I'm using is the following
    select distinct did.TABLE_NAME, did.COLUMN_NAME 
    from     
        (Select * from ALL_TAB_COLS 
        where column_name in('SO_LINE_ID','SO_LINE_NUMBER', 'SO_ORDER_NUMBER', 'SO_HEADER_ID','AR_CUSTOMER_TRX_LINE_ID')
        --and OWNER = 'FTBV'
        ) did 
    join 
        (Select * from ALL_TAB_COLS 
        where column_name in('SCHED_DISTRIBUTION_ID', 'CODE_COMBINATION_ID', 'PRODUCT_BUSINESS_CODE', 'PRODUCT_GROUP_CODE', 'PRODUCT_CODE')
        --and OWNER = 'FTBV'
        ) iii
    on did.TABLE_NAME = iii.TABLE_NAME;It's giving me limited results.
    What I need is something that can find interim tables that would link my two tables together based on the unique columns I've provided. Does such a query exist?
    Thanks in Advance.

    Only if there is a defined foreign key relationship. If there is one the queries you want are on the Constraints page of Morgan's Library at www.psoug.org. If they do not exist then you need to find a subject matter expert that can explain the application's design.
    The fact that you are asking this question is a strong indication of a lack of proper documentation at your facility: Something you might wish to address.

  • Error importing table metadata with quoted column names

    Hey folks,
    I have a strange problem with the table metadata import wizard. It refuses to import column names that are quoted. I am using OWB 11.1.0.6 on Oracle 11g/Linux
    For example, given this table
    create table mytest (id integer, "Name" varchar2(50))
    OWB imports the ID column just fine but chokes on the "Name" column ("Created with second class object failure").
    However if I define the table as
    create table mytest (id integer, Name varchar2(50))
    everything goes smoothly. Does anyone know if this is a bug or a feature? Can't find any information on this, and it's highly annoying as I'm importing definitions of automatically generated tables that contain tons of these quoted column names :(.
    I appreciate your help!!
    Thanks,
    Stefan

    I noticed that myself in our project.
    Our varchars2 are defined as VARCHAR2(xxx CHAR) - OWB puts the size*4
    In fact if you have special characters like umlauts (ü,ä,ö,...) it will use 4 bytes per character.
    You can try it yourself. Define a Varchar2(1 CHAR) and manually change the size of the Column in your mapping inside OWB (in filters, joins or your target table).
    Then shoot an umlaut through the mapping and will end up with a "too small" error.
    Dont mind the size*4 issue - we totally ignored it and run without error since 4 years now.

  • A table based on 400 columns

    Hi ,
    What is the best way to create a dummy table which has 400 columns ,the column names being known?
    Thanks.

    Some of Oracle's limits are based on the checkbox on the sales brochure theory ... not on relational reality.
    I have a table I am working with right now that has 921 columns. Designed by someone else at some distant point in the past and coming from a 1PB dataware house I am working with.
    I can not tell you what I think of the design in this forum and maintain my relationship with Oracle: Use your imagination and somewhere in the phrase you dream up use the phrase "full frontal."

  • How To Create Table View With Same Column name But Different Table?

    Hi All,
    I have the problem to create a tableview with same column name but in different table.
    The Table that i have:-
    Table - PAC051MPROFORMA
    Column - mrn,visitid
    Table - PAC051TPROFORMA
    Column - mrn,visitid
    Table - PAC052MTRANSBILL
    Column - mrn,visitid
    Then i want to create a table view to view that table. This is my SQL
    CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
    As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
    where
    *(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
    and
    *(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
    That SQL Return this error = ORA-00957: duplicate column name
    Then I modify that SQL to
    CREATE VIEW pacviewproforma (mrn,visitid)
    As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
    where
    *(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
    and
    *(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
    This time this error return = ORA-01730: invalid number of column names specified
    What should i do?
    Thanks...

    Hi,
    SQL> CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
      2  As Select
      3  PAC051MPROFORMA.mrn,
      4  PAC051MPROFORMA.visitid,
      5  PAC051TPROFORMA.mrn,
      6  PAC051TPROFORMA.visitid,
      7  PAC052MTRANSBILL.mrn,
      8  PAC052MTRANSBILL.visitid
      9  from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
    10  where
    11  (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
    12  and
    13  (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
    CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
    ERROR at line 1:
    ORA-00957: duplicate column namePlease give different names to each column.
    Something like this..
    SQL> CREATE OR REPLACE VIEW pacviewproforma (MPROFORMA_mrn,MPROFORMA_visitid,TPROFORMA_mrn,TPROFORMA
    _visitid,MTRANSBILL_mrn,MTRANSBILL_visitid)
      2  As Select
      3  PAC051MPROFORMA.mrn,
      4  PAC051MPROFORMA.visitid,
      5  PAC051TPROFORMA.mrn,
      6  PAC051TPROFORMA.visitid,
      7  PAC052MTRANSBILL.mrn,
      8  PAC052MTRANSBILL.visitid
      9  from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
    10  where
    11  (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
    12  and
    13  (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
    View created.
    SQL> DESC  pacviewproforma;
    Name                                      Null?    Type
    MPROFORMA_MRN                                      NUMBER
    MPROFORMA_VISITID                                  NUMBER
    TPROFORMA_MRN                                      NUMBER
    TPROFORMA_VISITID                                  NUMBER
    MTRANSBILL_MRN                                     NUMBER
    MTRANSBILL_VISITID                                 NUMBER
    ORA-01730: invalid number of column names specifiedThe list of column nmae you specified during the CREATE VIEW should match with the SELECT list of the view.
    Twinkle

  • Compare two tables based on two columns

    Hi,
    my tables looks like this:
    Desc Table A (account)
    Account1_id
    Account2_id
    name,
    empid
    Table B (Bill )
    BillNo
    Advertiserid
    agencyid
    total vvalue
    I need to pick up total value from table B where the unique combination of advertiser-Agency id is the same as the given account1_id -Account2_id combination in table A for each employee id.
    In other words my output should be like
    Empid | Account_id (should be same as advertiserid)| Account2_id (same as agencyid) | sum(total_value) for this adv-agency combination.....
    objective: Get the total value from table B for each unique account1-account2 combination (advertiser-agency in other words) .
    I am not sure if I should use a coreelated subquery or how to handle the situation....Right now I am just checking the two columns separately like this:
    select.......from a,b
    where b.advertiser_id = a.account1_id and b.agencyid = b.account2id
    Is it correct to do so? I have a feeling that I am missing something if I join them seperately like this......Any advice on this?
    I am using Oracle 10g. Hope I am clear.Please let me know. Thankx in advance.

    Here you go:
    SQL> WITH bill AS
      2  (
      3          SELECT 1000 AS billno, 101 AS advertiserid, 102 AS agencyid, 5000 AS total_value FROM DUAL UNION ALL
      4          SELECT 1001, 101, 103, 5000 FROM DUAL UNION ALL
      5          SELECT 1002, 101, 102, 1000 FROM DUAL
      6  ), account AS
      7  (
      8          SELECT 101 AS account1_id, 102 AS account2_id, 'John' AS name, 50 AS empid FROM DUAL UNION ALL
      9          SELECT 101, 103, 'James', 40 FROM DUAL UNION ALL
    10          SELECT 101, 105, 'Joe', 60 FROM DUAL
    11  )
    12  /* End Sample Data */
    13  SELECT a.name
    14       , a.empid
    15       , a.account1_id
    16       , a.account2_id
    17       , SUM(b.total_value)
    18  FROM   account a
    19  JOIN   bill    b ON  a.account1_id = b.advertiserid
    20                   AND a.account2_id = b.agencyid
    21  GROUP BY a.name
    22         , a.empid
    23         , a.account1_id
    24         , a.account2_id
    25  ;
    NAME                 EMPID          ACCOUNT1_ID          ACCOUNT2_ID   SUM(B.TOTAL_VALUE)
    John                    50                  101                  102                 6000
    James                   40                  101                  103                 5000

  • Import flat file to multiple tables based on identifier column

    Hello,
    I am trying to setup a package that will import one pipe-delimited flat file (a utility bill) to multiple data tables based on the value of the first column.  I have been told it is similar in format to an EDI file, but there are some differences.
    The number of columns is consistent where the first columns are the same.  Meaning a record that has '00' in the first column will always have 10 columns; a record that has '01' in the first column will always have 9 columns; etc.
    Each value in the first column represents a separate destination data table.  Meaning a record that has '00' in the first column should be output to table '00'; a record that has '01' in the first column should be output to table '01'; etc.  All
    destination tables reside on the same SQL Server.
    Identifier columns can repeat multiple times throughout the flat file.  Meaning a record that starts with '01' may be repeated multiple times in the same.
    Sample Data:
    00|XXXXXXXX|XXX|XXXXXXXX|XXXXXX|XXXX|X|XXXXXXXXXX|XX|XXXXX
    01|XXXXXXXXXXX|XXX|XXXXXXXX|XXXXX|XXXXXXXXXXXXXXXXXXXX|XXXXXXXXXX|XXXXXXX|XXXXXXXXXXXXXX
    02|XXXXXXXXXXX|XXXXXXXX|XXXXXXX|XXXXX|XXXXX|XXXXX|XXXXX|XXXXX|XXXXX|XXXXX|XXXXX
    04|XXXXXXXXXXX|XXXXXXXXXXXXX|XXX|XXXXXXXX
    05|XXXXXXXXXXX|XXXXXXXXXXXXX|XXX|XXXXXXXX|XXXX
    07|XXXXXXXXXXXXX|X|XXXXXXXXXXXXXXX|XXX|XXXXXXXX|XXXX|XXXXXXX|XXXXXXXXXXX
    07|XXXXXXXXXXXXX|X|XXXXXXXXXXXXXXX|XXX|XXXXXXXX|XXXX|XXXXXXX|XXXXXXXXXXX
    07|XXXXXXXXXXXXX|X|XXXXXXXXXXXXXXX|XXX|XXXXXXXX|XXXX|XXXXXXX|XXXXXXXXXXX
    07|XXXXXXXXXXXXX|X|XXXXXXXXXXXXXXX|XXX|XXXXXXXX|XXXX|XXXXXXX|XXXXXXXXXXX
    01|XXXXXXXXXXX|XXX|XXXXXXXX|XXXXX|XXXXXXXXXXXXXXXXXXXX|XXXXXXXXXX|XXXXXXX|XXXXXXXXXXXXXX
    02|XXXXXXXXXXX|XXXXXXXX|XXXXXXX|XXXXX|XXXXX|XXXXX|XXXXX|XXXXX|XXXXX|XXXXX|XXXXX
    04|XXXXXXXXXXX|XXXXXXXXXXXXX|XXX|XXXXXXXX
    Any help would be appreciated.

    Hi koldar.308,
    If there are few distinct values in the first column, we can use Flat File Source connect to that flat file, then use Conditional Split Transformation to split the first column to multiples, and then load the data to multiple tables with OLE DB Destination
    based on the outputs of Conditional Split.
    After testing the issue in my environment, please refer to the following steps to achieve this requirement:
    Drag a  Flat File Source connect to that flat file with Flat File Connection Manager.
    Drag a Conditional Split Transformation connects to the Flat File Source.
    Double-click the Conditional Split Transformation, add several Output based on the first column values as below:
    Drag same number OLE DB Destinations as the outputs of Conditional Split, connect to Conditional Split with one case output:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

  • SSMA for Sybase - Table Not Load: Invalid Column Name fill_factor

    I am trying to convert from Sybase 11.5 to SQL 2005 and when I refresh from database I receive the following errors.  Fill_Factor is not a column in the tables in Sybase.  Any thoughts on what might be going on?
    Analyzing metadata...
    Converting procedure Mortality.dbo.proc_exposure_1 ...
    Sybase Server Object Collector error: table : company_mortality_rate_tbl
         [Native Error code: 207]
    [DataDirect ADO Sybase Provider] Invalid column name 'fill_factor'.
         Error occurred while loading content.
    Sybase Server Object Collector error: table : study
         [Native Error code: 207]
    [DataDirect ADO Sybase Provider] Invalid column name 'fill_factor'.
         Error occurred while loading content.
    Converting procedure Mortality.dbo.proc_mortality_output ...
    Sybase Server Object Collector error: table : sysindexes
         [Native Error code: 207]
    [DataDirect ADO Sybase Provider] Invalid column name 'fill_factor'.
         Error occurred while loading content.
    Sybase Server Object Collector error: table : sysindexes
         [Native Error code: 207]
    [DataDirect ADO Sybase Provider] Invalid column name 'fill_factor'.
         Error occurred while loading content.
    Sybase Server Object Collector error: table : exposure_array
         [Native Error code: 207]
    [DataDirect ADO Sybase Provider] Invalid column name 'fill_factor'.
         Error occurred while loading content.
    Sybase Server Object Collector error: table : mortality_rate_table
         [Native Error code: 207]
    [DataDirect ADO Sybase Provider] Invalid column name 'fill_factor'.
         Error occurred while loading content.
    Converting procedure Mortality.dbo.proc_study_work_1 ...
    Sybase Server Object Collector error: table : study_working
         [Native Error code: 207]
    [DataDirect ADO Sybase Provider] Invalid column name 'fill_factor'.
         Error occurred while loading content.
    Sybase Server Object Collector error: table : study_working
         [Native Error code: 207]
    [DataDirect ADO Sybase Provider] Invalid column name 'fill_factor'.
         Error occurred while loading content.

    Hi,
    Even I am getting the same error when trying to see the table structure in sybase from SSMA tool. 
    Sybase Server Object Collector error: table : EFTArchive_bk2
         Invalid column name 'fill_factor'.
         Error occurred while loading content.
    I am not sure how to fix this. 
    This answer doesn't help me. "In SQL Server 2005 the fill_factor is spelled as FILLFACTOR." As I am
    getting this error sybase database itself.  
    I am using SSMA to migrate data from sybase to sql. when I select the tables in sybase, I am getting
    above error. (Invalid column name "fill_factor") 
    Could some please help me how to fix this error?

  • Query to list tables with a particular column name in a schema!!

    Is there any way to know?
    Thanks in advance.

    You can query the data dictionary views to get this information.
    For example
    untested
    select table_name
    from user_tab_columns
    where column_name = 'my particular column name';There is also all_tab_columns and dba_tab_columns. Both of which would include the schema name.
    Edited by: Sven W. on Sep 9, 2011 2:24 PM

  • How to restrict the entries of a database table based on the user name

    Hi All,
    I have created a Database Table. Table maintenance generator is generated for the table.
    UNAME(user name) is one of the fields in the table. whenever the user creates a new entry, the field UNAME will be populated automatically with SY-UNAME value. I have used Table event '05' to do this.
    My requirement is...
    When a user tries to maintain the entries of the table using SM30, when 'DISPLAY' is chosen, all the records of the table should be displayed.
    When 'MAINTAIN' is chosen, only those records which have UNAME = SY-UNAME(User Logged in) should be in EDIT mode. and rest all the records should be in DISPLAY mode(greyed out). It should allow to edit only those records which are created by the user logged in.
    Could you please tell me how to do this..? Thanks in advance.
    Thanks & Regards,
    Paddu.

    HI,
    In table main. gen there are number of events , try to select one event like 05 for the Sy-uname.
    For the  requirement:
    In that event write the code like
    this is basic idea not the code:
    Case ' Sy-ucomm'.
    when 'display'.  " button
       Nomally for the display button it will show all the records, but we need to write a code like this.
    select all records frm the table.
    ( Need to write the code in case if the user first maintained the data then again press the display , list has to be refreshed.)
    when ' Maintain'. " button.
    Fetch the records that are with SY-UNAME and find out the edit function and implement it on each and every record.
    endcase.
    Thanks and Regards,
    Bharani.

  • Search for columnName and Split data based on that column name

    Hi All,
    I have a table with one column, lets say Notes of datatype varchar(max).
    Source Date:
    Notes
    ABC:123:XYZ Dept:IT NameID:1 Name:Tom Hummer Date:04/12/2004
    456789:CDEF:ADEF
    CBD:12/12/2000:ZXCV Dept:HR NameID:1 Name:Sam Dope Date:06/17/2005
    I want Output should look like below. It should split data at 'Dept:' and 'Name:' I need SQl code  for SQL Server 2008 R2
    Output:
    Notes
    Dept:IT Name:Tom Hummer
    Dept:HR Name:Sam Dope
    Thanks,
    RH
    sql

    Hello,
    Please refer to the following statements:
    create table notes (note varchar(max));
    insert into notes values
    ('ABC:123:XYZ Dept:IT NameID:1 Name:Tom Hummer Date:04/12/2004'),
    ('456789:CDEF:ADEF'),
    ('7890:RST:QWER Dept:Sales NameID:2 Name:Mike Kule'),
    ('CBD:12/12/2000:ZXCV Dept:HR NameID:1 Name:Sam Dope Date:06/17/2005')
    select case
    when charindex('Name:',note)>0 and charindex('Date:',note)>0
    then SUBSTRING(note,charindex('Name:',note)-1,charindex('Date:',note)-charindex('Name:',note))
    when charindex('Name:',note)>0 and charindex('Date:',note)=0
    then SUBSTRING(note,charindex('Name:',note)-1,len(note)-charindex('Name:',note))
    end as name
    from notes
    where charindex('Name:',note)>0
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Filtering a Power Query Table Based on a Column That's a Table

    I have a table produced by an outer join ... 
    "Bananas" is not one of [My Fruit] values.  I'd like to filter my join results to only include [My Fruit] values, and I thought I could do that without expanding "NewCol".
    Am I mistaken in my belief that such a selection can be done without expanding the "NewCol"?

    hi Mark Weisman,
    I suppose your [My Fruit] value is single values. You can try below :
     Table.SelectRows( Join1,  each  List.Contains( [NewCol] [Fruit] , [My Fruit] ) )
    Note: [Fruit] is the column that contain value want to filter.
    Below is my testing sample :
    let
        Source = Table.FromRows({ {"North", "Apples"}, {"North", "Orange"}, {"West", "Bananas"},{"West", "Lemon"}}, {"Region", "Fruit"}),
        Group = Table.Group(Source, {"Region"}, {{"NewCol", each _, type table}}),
        Select = Table.SelectRows( Group, each List.Contains( [NewCol] [Fruit] , "Lemon" ) )
    in
        Select
    Regards,

  • Sorting A Table Based on single Column

    Hi,
    I wrote the piece of code to sort a webdynpro Table.
    wdContext.nodeKMAccess().sortElements(
         new Comparator()
         public int compare(Object x, Object y)
         int iX,iY;
         IPrivateDownloadKMHitsReportView.IKMAccessElement rx = (IPrivateDownloadKMHitsReportView.IKMAccessElement)x;
         IPrivateDownloadKMHitsReportView.IKMAccessElement ry = (IPrivateDownloadKMHitsReportView.IKMAccessElement)y;
         iX = Integer.parseInt(rx.getHits());
         iY = Integer.parseInt(ry.getHits());
         rx.getHits().compareTo(ry.getHits());     
         return (iY-iX);     
    But it sorts like
    11
    10
    8
    6
    3
    1
    2
    It sorts correctly, except for 2 values. Instead of 2 ,1... It gives 1,2. Where is the problem? how can i solve this isuue? Can anyone please help me in fixing this error?
    Regards,
    Divya

    Hi,
    try to change the comparator as follows
    public int compare ( Object obj1, Object obj2 ) 
       int i1 =  (  ( Integer ) obj1 ) .intValue (  ) ;
       int i2 =  (  ( Integer ) obj2 ) .intValue (  ) ;
       return Math.abs ( i1 )  - Math.abs ( i2 ) ;
    Regards
    Ayyapparaj

Maybe you are looking for