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 got the below error message when running this script


DECLARE
The 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
RUN IMMEDIATELY "SELECT COUNT (*) FROM" | T1.table_name | 'WHERE ' | T1.column_name | ' =: 1' IN 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 not correctly completed command.
ORA-06512: at line 7
00933 00000 - "not correctly completed SQL command.
* Cause:
* Action:


Any help please

If you are running this as a different user than the ADMIN you will also need to add the schema name.

EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' ||t1.owner||'.'||t1.table_name|| ' WHERE ' ||t1.column_name || ' = :1' INTO cnt USING v_data;

The error could be any strange names of tables or columns. For example, if they contain spaces in the name.
If you have names, then all identifieres must be placed in "."

+ untested example +.
{code}
RUN IMMEDIATELY "SELECT COUNT (*) FROM" ' | "" T1. Owner: ' ». » ' || T1.table_name | " » OÙ « ' || T1.column_name | "" =: 1' IN cnt USING v_data;
{code}

Tags: Database

Similar Questions

  • Oracle how to multiply two columns of different tables and results

    Oracle how to multiply two columns of different tables and get the result in the third column?

    I want to multiply all the lines of the quantinty column in the table of quantity with the relevant lines of the table of prices price column and get the result of multiplying in the third column. What should I use procedure trigerr? OR IS IT POSSIBLE HOW TO DO IT PLEASE HELP :D

    Edited by: 994229 2013-03-15 12:44
    /* Formatted on 3/15/2013 3:51:08 PM (QP5 v5.185.11230.41888) */
    CREATE TABLE mytable1
    AS
       (SELECT 1 id, 5 VALUE FROM DUAL
        UNION ALL
        SELECT 2, 7 FROM DUAL
        UNION ALL
        SELECT 3, 8 FROM DUAL);
    
    CREATE TABLE mytable2
    AS
       (SELECT 1 id, 4 VALUE FROM DUAL
        UNION ALL
        SELECT 2, 12 FROM DUAL
        UNION ALL
        SELECT 10, 12 FROM DUAL);
    
      SELECT id,
             mytable1.VALUE,
             mytable2.VALUE,
             mytable1.VALUE * mytable2.VALUE product
        FROM mytable1 FULL OUTER JOIN mytable2 USING (id)
    ORDER BY id;
    
    ID     VALUE     VALUE_1     PRODUCT
    1     5     4     20
    2     7     12     84
    3     8
    10          12     
    
  • Inventory of the data of all Tables in a database

    Hello
    We do the analysis of the existing data base (Oracle 10 g) and I want to prepare an inventory of the data of all tables in a database that is

    1. total number of records in a table
    2. total number of records that have null values in a column
    3. total number of standalone tables IE have no connection with other tables
    etc...

    Please let me know if there are tools or query that can do these tasks.

    Thank you and best regards,
    Lokesh
    select owner "Owner",
    table_name "Table_Name",
    column_name "Column_Name",
    initcap(data_type) ||
    decode(data_type,
    'CHAR', '('|| char_length ||')',
    'VARCHAR', '('|| char_length ||')',
    'VARCHAR2', '('|| char_length ||')',
    'NCHAR', '('|| char_length ||')',
    'NVARCHAR', '('|| char_length ||')',
    'NVARCHAR2', '('|| char_length ||')',
    'NUMBER', '('||
    nvl(data_precision,data_length)||
    decode(data_scale,null,null,
    ','||data_scale)||')',
    null) "Type",
    nullable "Nullable",
    decode(to_char(num_distinct),
    0,'No',
    'YES') "Have Data",
    owner sdev_link_owner,
    table_name sdev_link_name,
    'TABLE' sdev_link_type
    from sys.dba_tab_columns
    where (:OWNER is null or instr(owner,upper(:OWNER)) > 0)
    and (:TABLE_NAME is null or
    instr(upper(table_name),upper(:TABLE_NAME)) > 0)
    and (:COLUMN_NAME is null or
    instr(upper(column_name),upper(:COLUMN_NAME)) > 0)
    and substr(table_name,1,4) != 'BIN$'
    and substr(table_name,1,3) != 'DR$'
    order by owner, table_name, column_id
    

    I added a new column with an alias "get data". This new column will display "NO" is the entire column is zero and 'YES' if there is even a value not null in the column. But caution is that statistics table must be updated to get the correct results.

    Thus, it may be useful to gather current statistics before executing the query.

    Exec dbms_stats.gather_schema_stats or even dbms_stats.gather_database_stats.

  • How to remove a column from a table in a dell identtiymananger 7.0

    How to remove a column from a table in a dell identtiymananger 7.0

    Hello

    In Version 7 of the removal of a single custom column can be accomplished by a stored procedure, available in the database called: QBM_PColumnDrop

    Hope that helps.

    Cordially Fatih

  • How to convert * all * tables of text in a document?

    Version: Indesign CS 5.5

    I have a massive document that was given to me after be imported into Word, and the person who has imported, it did not convert tables to text (or they tried and it did not work, be it, I have a huge amount of tables that must be not filed).

    I am responsible for the document formatting, and the formatting requirements are to convert all tables in the text document. I was able to batch-process other formatted in the document with the help of find + replace, but I can't seem to find a way to search for all instances of a table in the document and convert all the table set in shape to the text. I can find every table in the search/replace tool using < 0016 >, but I have no idea how, and then delete the table set shaped with the change function.

    I have no text special requirements (standard; tabs for columns and new paragraphs for the lines) and all tables should be converted, regardless of their formatting or content, so it's fairly simple formatting.

    There must be SOME way tot automate this process, it seems incredibly Loïc having to select each table individually and go up to the menu to select "convert table to text... '. ». Any idea is appreciated.

    Click on the text cursor in your text running, and then run this Javascript. WARNING: fully typed memory!

    App.Selection [0].parentStory.tables.everyItem () .convertToText ();

  • How to find all tables without Unique constraints

    How can I write a design rule that lists all tables with no UKs on them?

    Hello Kent,

    Try this

    function checkUKs(table){
    ruleMessage="";
    if(table.getUKeys().size() == 0){
      ruleMessage="no UKs";
      errType="Problem:";
      return false;
    } else {
      return true;
    }
    }
    checkUKs(table);
    
  • How to delete all TABLEs in the schema SYS that are created from 09:15?

    Unfortunately a script created a lot of tables in the diagram (= SYS) and bad Tablespace (= SYSTEM).

    How can I delete all TABLES that are created inTablespace = SYSTEM and SCHEMA = SYS (in a DDL command)
    respectively for the past 3 hours from 09:15 to 25 Sep 2011?

    Alternative: How can I move these tables in another schema (for example ATEST) and Tablespace (USERS)?
    Is this possible with Oracle XE or Oracle Enterprise?

    Peter

    You can use ALTER TABLE... MOVE. It offers a TABLESPACE clause, which allows you to choose a different tablespace as target. Refer to the documentation for your version of the database.

  • How to create the column of the table for long-form Master detail relationship

    Apex 4.1

    Oracle 11g

    I created a form master detail and see the main table hotel_list and table hotel_mapping as detailed below.

    Hotel_list

    ID HOTEL_NAME

    1 Holiday Inn

    Hotel Hilton 2

    Hotel_mapping

    ID HOTEL_NAME MAPPING_NAME

    1 Inn Holiday Inn Select hotel

    2 holiday hotel Holiday Inn Select

    3 hotel Holiday Inn Holiday Inn Hotel

    4 Hilton Hotel Hilton Hotel chain

    Hotel Hilton 5 HiltonHotel

    Table Hotel_name Hotel_list is a linked table Hotel_mapping

    When I add a line to the Hotel_mapping table for the selected row in the hotel_list table, mapping_name of column is null, therefore impossible to create the relationship between the main table and the secondary table.

    I would like to know, how to create the relationship?

    Thank you very much

    Best regards

    Yong Huang,

    simple step see creating a form detailed master with APEX - Assistant Master retail

    and check how to maintain the relationship between two tables,

    simple return the packaged application «Sample of Masters details»

    and try to understand this concept...

    In your example, use Hotel_list.ID as a foreign key in the table Hotel_mapping

    and maintain the relationship with the column ID...

    and choose the display type of the column Hotel_list.ID in table Hotel_mapping as List(Query Based LOV) select.

    otherwise the best way is to create sample on oracle.apex.com

    I hope this helps...

    Leave.

  • How to extract the data in the table in the database

    Hi all

    IM using PHP/MySQL and I use implode () function to store several values of checkboxes that have been selected in the form. Does store the word 'Table' in my database. How can I get back all of each data I've been record before (each of the checked instead of the word Array value)?

    If you don't have that in the database is the Word table, that's all you'll get back out. It sounds like you do not store the information correctly.

    Let's say that your form contains a series of checkboxes, all are called options. For all values, you must add square brackets after the name in the form:

    Sun roof
    Satellite navigation
    Air conditioning

    If the form is submitted using the POST method, the values will be stored in an array called $_POST ['options']. To store in the database, you must check whether the table exists and then use implode ():

    if (isset($_POST['options'])) {
      $options = implode(',', $_POST['options']);
    } else {
      $options = '';
    }
    

    Then insert $options into the database.

  • Amount from column of a table of a database link

    Hello community of the oracle,

    I can access an external database via a database link. is it possible in SQL or PL/SQL to get the number of columns in a table known? External database systems can be different, MySQL for now, but in future DBMS such as MSSQL. All I need is the number of columns.

    Ikrischer

    is it possible in SQL or PL/SQL to get the number of columns in a table known?

    Do you mean smth like

    select count(*) from all_tab_columns@remote_db where table_name = 'YOUR_TABLE_NAME'
    

    ?

  • How to get ALL of the 'real' database table in apps/apps

    Hi all

    EBS R12.2

    OEL 6

    I create tables derived from drawing apps and custom drawing.

    When I connect to apps/apps, there are a lot of objects, synonyms, views that point to other tables, synonyms, views of another schema as AP, AR, GL, etc..

    What is confusing is a view contains a table attached, then it is created with a synonym of an another synonyms joined another scheme.

    How can I get the list of actual tables being accessed from these apps objects?

    I would also like to count the lines of ALL the actual tables and get their real value.

    Thank you very much

    JC

    See the answers here >DBA_DEPENDENCIES

  • How to dynamically add columns to the table

    Hi all

    I'm new to ADF and need help on sub condition.

    We have created a ViewObject on the EMPLOYEE table that has under columns:

    EMP_ID,

    EMP_NAME,

    DEPARTMENT,

    COST_CENTER,

    BUSINESS_UNIT

    COUNTRY

    GCODE

    We need to create a page in the ADF with employee table to show only below the columns

    EMP_ID,

    EMP_NAME,

    DEPARTMENT,

    COST_CENTER

    Later, if necessary user should be able to add other columns to the page dynamically.

    Can you please advice on how to implement this feature.

    Thank you.

    Kind regards

    Vidya

    Hello.

    There could be a simple solution, which is to use the component PanelCollection.

    Drag ' drop your VO to a page and create a Table with all the attributes.

    For columns that emp_id, emp_name, cost_center, set the Visible property to false.

    Put the PanelCollection component on your page and drag your table inside.

    When you run the page you will see the view menu in the upper left corner of the table above. You can show/hide columns in this menu.

  • How to disable specific columns in a table

    Hello world

    There are two buttons in my code (SHIFT and general). When I press the SHIFT key, general column should disable & grey outside, but all three move the columns (Shift1, Shift2, Shift3) should be in an editable state. Like the picture below

    and then vice versa case (if I press the general button). Like the picture below

    There is no action in the table if the two push button on a high value. I guess that there must be an easy fix, but I just couldn't get there. Please understand it.

    Thanks in advance.

    Use a semi-transparent image on the columns to turn off.  Make the visible decoration or not depending on the State of the Boolean value.   The columns will be always 'on' but will be not clickable.

  • How to hide the column in a table in the adf.

    I created the table of the ADF and surround it in the collection of panels, the data in the table from the bean to support variable. Depending on the State, there are a few columns that must hide with the user. I used visible = "false", where the false value will come from backing bean. However the user to the table always have the ability to display the column. Is there any one to hide the column with the user at all times. Fixing the code example:

    < af:column sortable = "false" headerText = "column1" id = "c13" visible = "false" >

    "" < af:outputText value = "{row.columns1} ' id ="ot13"/ >

    < / af:column >

    Hello

    Use the rendered property?

    Concerning

  • How to update exists column on the table with the exact number and auto increment

    Hello

    I have a table with more than 10 million rows and there is a column called 'number_zaq', I want to update this column on line frist from 2000 and + 1 for the next all ranks.

    Update your_table

    Set number_zaq = rownum + 2000-1;

Maybe you are looking for

  • playmemomories constantly hangs at startup

    with the new update of game el capitan memories constantly crashes at startup you can help me please

  • Recovery disk does not work?

    Good then last week, I ordered a system recovery kit, as in somehow the part in my Pavilion dv7 was damage / deleted. Today, it happens so I did what he told me to do in the book which basically said "use recovery manager, insert the 1 system recover

  • is it possible to display on my screen QHD? -want to M6 i5-4200u

    I'm sorry that I can't well English I recently bought my laptop (i5-4200u want m6 k025dx model) and I'm trying to find the manual but I can't find an answer. Please help me I want my output by desire m6 QHD screen, but is it possible? M6 doesn't have

  • 23 f250 Pavilion all-in-one: How do the BIOS on my card MOM Amd Bolton-d3s?

    I wonder how do I get my amd bolton-d3s in the motherboard BIOS. And if you know can you please tell me how to get to the advanced chipset features. P.S. I have a Pavilion All In One 23 f250 with the original motherboard. Please answer as soon as POS

  • re-installed windows vista and I lost my desktop folder

    Circumstances beyond my control (WGA problem), I was forced to reinstall vista on my laptop. I took care to save all the data I needed... almost. I need to get one of the contents of the folder that was on my desktop. When I reinstalled vista, he ren