How to search all columns of all tables in a database

i need to search all columns of all tables in a database , i already write the code below , but i've got the error message below when run this script
DECLARE
cnt number;
v_data VARCHAR2(20);
BEGIN
v_data :='5C4CA98EAC4C';
FOR t1 IN (SELECT table_name, column_name FROM all_tab_cols where owner='admin' and DATA_TYPE='VARCHAR2') LOOP
EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' ||t1.table_name|| ' WHERE ' ||t1.column_name || ' = :1' INTO cnt USING v_data;
IF cnt > 0 THEN
dbms_output.put_line( t1.table_name ||' '||t1.column_name||' '||cnt );
END IF;
END LOOP;
END;
Error report:
ORA-00933: SQL command not properly ended
ORA-06512: at line 7
00933. 00000 - "SQL command not properly ended"
*Cause:   
*Action:
Any help please

SQL solutions by Michaels
michaels>  var val varchar2(5)
michaels>  exec :val := 'as'
PL/SQL procedure successfully completed.
michaels>  select distinct substr (:val, 1, 11) "Searchword",
                substr (table_name, 1, 14) "Table",
                substr (t.column_value.getstringval (), 1, 50) "Column/Value"
           from cols,
                table
                   (xmlsequence
                       (dbms_xmlgen.getxmltype ('select ' || column_name
                                                || ' from ' || table_name
                                                || ' where upper('
                                                || column_name
                                                || ') like upper(''%' || :val
                                                || '%'')'
                                               ).extract ('ROWSET/ROW/*')
                   ) t
--        where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
       order by "Table"or
11g upwards
SQL> select table_name,
       column_name,
       :search_string search_string,
       result
  from (select column_name,
               table_name,
               'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
          from cols
         where table_name in ('EMP', 'DEPT')),
       xmltable (str columns result varchar2(10) path '.')
TABLE_NAME                     COLUMN_NAME                    SEARCH_STRING                    RESULT   
DEPT                           DNAME                          es                               RESEARCH 
EMP                            ENAME                          es                               JAMES    
EMP                            JOB                            es                               SALESMAN 
EMP                            JOB                            es                               SALESMAN 
4 rows selected.

Similar Messages

  • How to search all columns of all tables in a database for a keyword?

    Dear Team,
    i have an requirement that : i want to search all the columns of all the tables in the particular database based on the specific key word or an free text.
    example :
    table 1: columns data
    empname sam
    empid 01
    table 2 columns data
    deptname sam
    departmentid 10
    table 3 columns data
    organization name sam
    organization id 1
    when i search for text " SAM"
    it should search me from the entire database, all tables and columns of it and display the result
    output : tablename cloumn value
    table1 empname sam
    table2 deptname sam
    table3 organizationame sam
    the example is just an sample not the real data .
    please help me with sample code or any link related to it .
    thanks in advance

    Hi justin , thanx for the reply
    the basic requirement that we required is ,
    the user will just type the keyword( value in the coumn) he required and it should search all the tables and columns of the table in the database and i have to show this in the front ent in the table format. here the user will analyse the information based on the search .
    it is just like the google search we does( type the keyword in free text) it will display the result.
    so for that i have to search entire table and columns in the whole database.
    please if any one provides me the solution it will be help full for me.
    thanx in advance

  • All columns of all table in one schema

    Hi
    All,
    Oralce 10.2.0.3
    I want to count all columns in all the table in one particular schema.
    How can I do that?
    which view i should use to count all cloumns of all tables in particular schema?
    Thanks

    vishal patel wrote:
    we needed for our data conversion project..I don't know how you'll use the number of columns in all a schema for data conversion. Some columns are duplicated (e.g. PK/FK), should they really count for two ?
    A data conversion means you should actually know what are the columns used for, not how many they are.
    one more question that count include hidden columns
    what is hidden column used for ? I can not see those columns in actual table.See here an example :
    Re: Difference btwn user_tab_cols & user_tab_columns
    Nicolas.

  • Aggregate of all Columns in each table for the entire schema

    I want to calculate the report of Aggregate of all Columns in each table for the entire schema in Oracle. Pls let me know which approach is best to do this.
    Thanks in advance !!

    Not sure about your requirement..
    This?
    select table_name,sum(data_length) sm
    from user_tab_cols
    group by table_name;                                                                                                                                                                                                                                                                           

  • ORA-12983: cannot drop all columns in a table

    Hi,
    I am creating a table with two columns.
    I have modified a column as unused using ALTER statement.
    After that i have tried to drop the another column by using ALTER statement.
    But it throws an error ORA-12983: cannot drop all columns in a table.
    is it not possible to achieve this via ALTER statement?
    thanks

    is there any other way to find the name of the columns which have been marked as unused?Don't think so, and you would not be able to do much about. You won't be able to reference it, you won't be able to un-unuse it, and you would even be able to add a new column having same name.
    Why are you using SET UNUSED in the first place?
    Regards
    Peter
    Quoting myself:
    You won't be able to reference itMaybe not good enough:
    SQL> select column_name, data_type, segment_column_id
      from user_tab_cols
    where table_name = 'T';
    COLUMN_NAME                    DATA_TYPE   SEGMENT_COLUMN_ID
    SYS_C00001_11051618:28:14$     NUMBER                      1
    B                              NUMBER                      2
    SYS_C00003_11051618:28:14$     NUMBER                      3
    3 rows selected.
    select "SYS_C00003_11051618:28:14$" from t
    Error at line 1
    ORA-00904: "SYS_C00003_11051618:28:14$": invalid identifier
    SQL> alter table t drop column "SYS_C00001_11051618:28:14$";
    Table altered.
    SQL> select column_name, data_type, segment_column_id
      from user_tab_cols
    where table_name = 'T';
    COLUMN_NAME                    DATA_TYPE   SEGMENT_COLUMN_ID
    B                              NUMBER                      
    1 row selected.
    Note: Both columns "disappeared"  Thanks MichaelS
    Edited by: Peter on May 16, 2011 9:29 AM

  • String Search Query in any columns in any table in a database

    Hi All,
    I am trying to search a word which starts with 'FRA' in any columns and any tables.
    I am unable tofind what is generating a join datasets in the webservice from teh database as it is not apparent within teh 100 tables.
    I ahve looked into
    Re: How to search in all rows and all columns?
    Re: SQL Search Query - HELP!
    but none of these queries is working out for me as I am a user with no tables on its own but rather a user quering other tables.I think its a tweak on which dat adisctionary I can view
    select distinct substr (table_name, 1, 14) "Table",
    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
    from all_cons_columns,
    table
    (xmlsequence
    (dbms_xmlgen.getxmltype ('select ' || column_name
    || ' from ' || table_name
    || ' where upper('
    || column_name
    || ') like upper(''%' || 'fra'
    || '%'')'
    ).extract ('ROWSET/ROW/*')
    ) t
    order by "Table";
    running teh above query got me thsi error:
    ORA-19202: Error occurred in XML processing
    ORA-00942: table or view does not exist
    ORA-06512: at "SYS.DBMS_XMLGEN", line 288
    ORA-06512: at line 1
    19202. 00000 - "Error occurred in XML processing%s"
    *Cause:    An error occurred when processing the XML function
    *Action:   Check the given error message and fix the appropriate problem
    Any help is much appreciated
    Edited by: CrackerJack on Sep 3, 2012 5:55 PM
    Edited by: CrackerJack on Sep 3, 2012 5:55 PM

    Hi,
    CrackerJack wrote:
    Hi All,
    I am trying to search a word which starts with 'FRA' in any columns and any tables.
    I am unable tofind what is generating a join datasets in the webservice from teh database as it is not apparent within teh 100 tables.
    I ahve looked into
    Re: How to search in all rows and all columns?
    Re: SQL Search Query - HELP!
    but none of these queries is working out for me as I am a user with no tables on its own but rather a user quering other tables.I think its a tweak on which dat adisctionary I can view In all_<b>cons</b>_columns, "cons" stands for "constraints". That view only includes columns that have a constraint on them. 
    Use all_<b>tab</b>_columns if you're interested in all columns in all tables.
    select distinct substr (table_name, 1, 14) "Table",
    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
    from all_cons_columns,
    table
    (xmlsequence
    (dbms_xmlgen.getxmltype ('select ' || column_name
    || ' from ' || table_name
    || ' where upper('
    || column_name
    || ') like upper(''%' || 'fra'
    || '%'')'
    ).extract ('ROWSET/ROW/*')
    ) t
    order by "Table";You may have noticed that this site noramlly compresses whitespace.
    Whenever you post formatted text (such as query results) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    When referencing a table in a differenct schema, you must qualify the table name with the owner (unless there happens to be a synonym).  For example, if you are connected as some user other than scott, and you want to use the emp table that is in the scott schema; then you can't just say "SELECT ... FROM emp;", because that would look for the emp table in yur own schema.  You have to say "SELECT ... FROM <b>scott.</b>emp;" instead.  If the table is in your own schema, then the scema name is optional.  The OWNER column in all_tab_columns gives the schema name.
    running teh above query got me thsi error:
    ORA-19202: Error occurred in XML processing
    ORA-00942: table or view does not exist
    ORA-06512: at "SYS.DBMS_XMLGEN", line 288
    ORA-06512: at line 1
    19202. 00000 - "Error occurred in XML processing%s"
    *Cause:    An error occurred when processing the XML function
    *Action:   Check the given error message and fix the appropriate problemSorry, I don't know what causes that error.
    If I use the data dictionary view cols (as in {message:id=3325696} which you cited), it runs correctly.
    If use what I though was the equivalent data dictionary view, user_tab_columns, or if I use all_tab_columns or other data dictionary views, then I get those errors.  I'm using Oracle 10.2.0.1.0.
    Edited by: Frank Kulash on Sep 3, 2012 10:45 PM
    John Spencer noticed the same problem 5 years ago.  See {message:id=1969268}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to Delete a Column in Internal Table

    Hi All,
    Does any one know ,How to Delete a Column in Internal Table?

    Hi,
       For deleting the column in the internal table, you have to eliminate the field which you want to delete.
    loop at itab into wa.
      move corresponding wa to wa1.
    append wa1 to itab1.
    clear wa1.
    clear wa.
    endloop.
    wa1 is the workarea without the field which you want to delete.
    itab1 is the internal table which consists of the deleted column.

  • How to find the column name and table name with a value

    Hi All
    How to find the column name and table name with "Value".
    For Example i have value named "Srikkanth" This value will be stored in one table and in one column i we dont know the table how to find the table name and column name
    Any help is highly appricatable
    Thanks & Regards
    Srikkanth.M

    2 solutions by Michaels (the latter is 11g upwards only)...
    michaels>  var val varchar2(5)
    michaels>  exec :val := 'as'
    PL/SQL procedure successfully completed.
    michaels>  select distinct substr (:val, 1, 11) "Searchword",
                    substr (table_name, 1, 14) "Table",
                    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
               from cols,
                    table
                       (xmlsequence
                           (dbms_xmlgen.getxmltype ('select ' || column_name
                                                    || ' from ' || table_name
                                                    || ' where upper('
                                                    || column_name
                                                    || ') like upper(''%' || :val
                                                    || '%'')'
                                                   ).extract ('ROWSET/ROW/*')
                       ) t
    --        where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
           order by "Table"or
    SQL> select table_name,
           column_name,
           :search_string search_string,
           result
      from cols,
           xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
           columns result varchar2(10) path '.'
    where table_name in ('EMP', 'DEPT')
    TABLE_NAME           COLUMN_NAME          SEARCH_STRING        RESULT   
    DEPT                 DNAME                ES                   RESEARCH 
    DEPT                 DNAME                ES                   SALES    
    EMP                  ENAME                ES                   JONES    
    EMP                  ENAME                ES                   JAMES    
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   SALESMAN 
    EMP                  JOB                  ES                   PRESIDENT
    EMP                  JOB                  ES                   SALESMAN 
    9 rows selected.

  • How do I Freeze Columns in HTML Tables

    How do I Freeze Columns in HTML Tables when scroll vertically as well as horizontally? (header and some columns on LHS). I generate a JSP report which got more than 1000 rows. Please advise. Thanks.

    Gooooooooooooooooogle searched "Freeze Columns in HTML Tables"
    So many solutions available !!!!!
    see the 1st link
    http://web.tampabay.rr.com/bmerkey/examples/locked-column-csv.html

  • How to sum the column in a table seperated by sign.

    How to sum the column in a table separate by sign.
    For Example:
    A B
    10 MOHAN
    -15 KUMAR
    -25 MARCH
    50 MAY

    SELECT  SUM(CASE SIGN(A) WHEN 1 THEN A ELSE NULL END) SUM_POSTIIVE,
            SUM(CASE SIGN(A) WHEN -1 THEN A ELSE NULL END) SUM_NEGATIIVE
      FROM  tbl
    /SY.

  • How to delete a column from the table control in module pool?

    Hi,
      can any one please tell How to delete a column from the table control in module pool?
    thanks in advance
    warm regards
    HareeshKumar N

    hi hareesh,
    I think it is better to hide it.
    How to hide: You can check this link
    Dynamic Hide column in table control

  • How to search records in a standard table with * ?

    Hi everyone,
    Can anyone tell me how to search records in a standard table with * ?
    That is, in screen if user type * abc * for searching the records in which the field MC_STEXT contains 'abc'. What the code should be? How to complete the code below?
      SELECT SINGLE objid FROM p1000  INTO p1000-objid,
      WHERE MC_STEXT = ? .
    Thanks!

    Hi
    There are several way to do that, probably just as some guys wrote the easier way is to use LIKE in WHERE condition and the sign % instead of *:
    V_STRING = '%ABC%'.
    SELECT SINGLE objid FROM p1000 INTO p1000-objid,
    WHERE MC_STEXT LIKE V_STRING.
    U can also use a range (just like select-options):
    RANGES: R_MC FOR P1000-MC_STEXT.
    R_MC-LOW = 'ABC'.
    R_MC(3) = 'ICP'.
    APPEND R_MC.
    SELECT SINGLE objid FROM p1000 INTO p1000-objid,
    WHERE MC_STEXT IN R_MC.
    Max

  • How can I select columns from a table EMP, using Select statement?.

    Hi Friends,
    How can I select columns from a table EMP?.
    I want to select columns of EMP table, using select statement.
    Please reply me urgently.
    Shahzad

    Something like this:
    scott@DBA> select empno,ename,job from emp;
         EMPNO ENAME      JOB
          7369 SMITH      CLERK
          7499 ALLEN      SALESMAN
          7521 WARD       SALESMAN
          7566 JONES      MANAGER
          7654 MARTIN     SALESMAN
          7698 BLAKE      MANAGER
          7782 CLARK      MANAGER
          7788 SCOTT      ANALYST
          7839 KING       PRESIDENT
          7844 TURNER     SALESMAN
          7876 ADAMS      CLERK
          7900 JAMES      CLERK
          7902 FORD       ANALYST
          7934 MILLER     CLERK
    14 rows selected.Check the documentation:
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#sthref9697
    Message was edited by:
    Delfino Nunez

  • All columns of trinidad table are not coming up on page while its running

    Hi,
    I have put two trinidad tables on my page.But while the page is run, I am unable to see all the columns of the table.Only a few columns are visible.
    Also, though there are 5 rows in teh table ,there is a lot of gap below the tablespace.So the next table comes after a very big gap.
    How to solve the above two problems? Kindly let me know your valuable suggestions.
    Regards

    Hi santosh,
    Following is my code.I am providing only one column code(similarly there are 3 more columns),along with the table code.
    <tr:table value="#{phonebeannew.inputphone}" var="row"
    rows="#{bindings.phone.rangeSize}"
    inlineStyle="height:#{phonebeannew.rownumbers + 275}px"
    id="t1" width="100%">
    <tr:column sortProperty="phonetype" sortable="false"
    headerText="phonetype"
    id="c3" width="5px">
    <tr:inputText value="#{row.phonetype}"
    simple="true">
    I gave width as 5px but it doesnt make any difference in output.
    The 'phonebeannew' is our bean and inputphone is a property of it.input phone holds the array of values for the 4 columns.
    Kindly let me know if you want any further information which I can provide
    Regards

  • Logging ALL Columns in a Table

    Hi I want to enable supplemental logging for all columns in table. So I issued the command
    'ALTER TABLE xxxx ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS:
    Now In that table I have 5 LOB colums,2 CLOBS and 2 Varchar2 columns and I dont want to log them but all the other columns.How to do this.Will logging all columns automatically reject LOBs and CLOBS???

    Use the following code for remove all the row in a table...
    call the DeviceClearTable()
    method in mouse event...
    public void DeviceClearTable()
         int numrows = DeviceModel.getRowCount();
              for(int i = numrows - 1; i >=0; i--)
                   DeviceModel.removeRow(i);
    Edited by: kumaravel on Jun 2, 2008 10:36 AM

Maybe you are looking for