How to find the name of a column in a table

Hi all

I have a Table that contains approximately 100 columns.


I need to find the column name, to find in specific columns containing data like 'abc '.

Ex: I have a table like temp_table_name
the columns are col1, col2, col3, col4, col5, col6, col7, col8,.... col99
I'm looking for with data specific like 'abc '.

Need to find the name of the table column that contains data of 'abc '.

Please suggest me. How to find in a single query... :-)

Actually I'm looking through a column of the table as below
Select count (*) in the temp_table_name where col1 = 'abc '.

FOR I IN 1.20 LOOP
ln_num_of_rows: = 0;
lv_column_name_search: = "col" | I have;

lv_sql: = ' select count (*) in the temp_table_name where ' | lv_column_name_search | "= abc";

EXECUTE IMMEDIATE lv_sql INTO ln_num_of_rows;

IF ln_num_of_rows > 0
-column found in lv_column_name_search
EXIT;
END IF;
END LOOP;

But I'm gettig performance problem.

How can I do this in any other alternative way? could you suggest any way possible as soon as POSSIBLE.

It's probably never going to be effective - realistic, you have to scan completes the picture.

You could probably improve a little things by doing something like

SELECT DISTINCT column_name
  FROM (
    SELECT (CASE WHEN col1 = 'abc' THEN 'col1'
                WHEN col2 = 'abc' THEN 'col2'
                WHEN col3 = 'abc' THEN 'col3'
                ...
                WHEN col20 = 'abc' THEN 'col20'
                ELSE NULL
                END) column_name
      FROM table_name
    WHERE col1 = 'abc'
        OR col2 = 'abc'
        ...
        OR col20 = 'abc'
  )

but it's never going to be incredibly fast.

Justin

Tags: Database

Similar Questions

  • How to get the name constraintlist and column in a table?

    Hello


    can someone please tell me how to get the type of constraint, and it is imposed on the names of columns in a table.




    Thank you
    Nico

    Hello

    Use the two tables:

    select * from all_constraints
    
    select * from ALL_CONS_COLUMNS
    

    Sorry SY, you were faster than me...

    Published by: user11268895 on August 19, 2010 13:27

  • How to find the name of the Oracle database server?

    People,

    Hello. I installed Oracle Database 11 g 2 OS Oracle Linux 5. The installed directory is/home/user/OracleDB_Home and/home/user/OracleDB_Base.

    Host name is "mylinux". Name of the database instance is PT853.

    I use "mylinux" as the name of the database server, it does not work. I use another way to do as below:

    Export ORACLE_HOME = / home/user/OracleDB_Home

    Can I use "mylinux ORACLE_HOME" as the name of the database server, it does not work either.


    My question is:

    How to find the name of the database server Oracle with Oracle Linux 5 OS?


    Thank you.

    You must learn the basic of database Oracle.

    Please don't regard it not same as SQL server in terms of configuration.

    You never specify the database server name in Oracle.

    You specify the host name in only two places, 1) Tnsnames.ora/JDBC/ODBC (or any client you want to connect) and listener.ora) 2.

    There was nothing called specify the name of the Oracle database from an oracle database server.

    Concerning

    Anurag.

  • How to find the names of tables that have more than 100 columns

    Hi gurus,

    Please help me find the names of the tables that have more than 100 columns in the database.

    Below will be useful for you.

    SELECT atc.OWNER,atc.TABLE_NAME,count(*)
    FROM all_tab_columns atc
    GROUP BY  atc.OWNER,atc.TABLE_NAME
    HAVING count(atc.COLUMN_NAME) > 100
    

    Adding another point, you can use user_tab_columns, all_tab_columns, dba_tab_columns, based on your needs/access.

    Thank you
    Suri

    Published by: Suri on February 23, 2012 11:30

  • How to find the name that differ just a little

    Hi all

    I wonder if is a short distance to find the name that differ for 2/3 characters;

    Example, I have a table that contains 1 varchar2 column.

    Martello

    point

    Pistola

    cemmello

    Cammelli

    I need to write a query like:

    Select * from table where colum = point

    in the result set, I want to

    point

    cemmello

    Cammelli

    Thank you

    F.

    Hello francy77

    In fact, it is not possible. There is a SQL "soundex" function, which "returns a string containing the phonetic representation of the char . This function allows you to compare the words that are spelled differently, but sound as well in English. »

    Example: Smith could be written as "SMYTHE".

    Try this:

    SELECT first_name

    FROM (SELECT 'Smith' AS the name OF DOUBLE UNION ALL

    SELECT 'Sophie' AS the name OF THE DOUBLE)

    WHERE SOUNDEX (first_name) = SOUNDEX ('Smythe')

    ;

    You get two records...

    But if you have a specific logic, then you must create a function and he set what text - what you want text input.

    Is it useful or the solution for you?

  • How to find the name of RDF file

    In our user environment final creating sales and registration. Order once saved will be printed directly from the toolbar selection-"print icon".

    How to identify the name of the report - the system is printing to change the same.

    Very R12.0.6

    Thank you

    Hello
    Once the request is submitted, go to view--> queries--> find.

    Compare with your report has already been submitted with the present report here.

    Copy the name of the report and the system administrator--> simultaneous--> program--> set.
    From here you can find the short name which is nothing other than the name of RDF.

    HTH
    -Arif.

  • How to find the name of the procedure call or a package?

    Hi all..

    Is it possible to find the name of the procedure or the calling package?

    I mean.. If proc_1 calls proc_2 how can I find in proc_2 proc_1 call?

    Proc_2 is called from a different procedure? I need to write to the size of the code that should fire depends on the Proc he calls?

    Please help me solve this problem.

    Thank you

    You could try OWA_UTIL. WHO_CALLED_ME
    "This procedure returns information (in the form of output parameters) on the unity of PL/SQL code that called it."
    See:
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14258/w_util.htm#sthref11492

  • How to find the name of the image in E10?

    Hi all

    This may be a simple question, but the question in the moment: is there a way to tell what image name is E10? I have an email with two images that I can't find the names. I tried hover, right-click, looking for a possible name, etc, nothing works! I believe in E9, you could just look at the details of the image, or open the HTML, y at - it something like this in E10? HTML is not an option, as this was built using the e-mail writer.

    Thank you very much!

    Hi Hayley,

    The best way to find the name of an image that was inserted in an email is to send a test e-mail. Upon receipt of the email, use the "Open web version" link to open the email in your browser. Once opened in your browser, right click on the email address and select the "View Page Source" option, this will display the HTML for email. If you follow the natural progression of the email from top to bottom, in among all the content text and code, you should be able to find the names of the image. They will look something like this http://images.response. "/ EloquaImages/clients***/{b823ae52-fb21-4532-882f-b1f4e9cb423b}_facebook.png" width = "27" height = "26" alt = "Facebook" > where facebook.png is the name of the image.

    I hope this helps.

    Tim

    LBDGA

  • With CVI SQL Toolkit, how to add the new variable param column in a table.

    Dear all:

    I used the CVI Sql toolkit to create a database, but now I don't know how to add a new column to a table in variable param.

    I know, to add a column with the name of constant column could be down by below:

    DBImmediateSQL ((hdbc, "alter table table1 add column1 char [100]");

    But if Column1 is a param variablae how can I write the code? Please advise?  It will be appreciated if you could give me an example.

    Best regards!

    HI -.

    If you look at the parameters that you pass to the SQL function, you can see that the second parameter is a string constant. In your code, you can create an array of characters (string). You can then use sprintf to programmatically determine what will be the contents of this variable. In the function call, you can put the variable instead of the literal string, and you will have a customizable SQL statement.

    Hope this helps-

    John M

  • How to set the value of a column in a table according to another column?

    Hello world!

    I use Apex 4.1.
    My question is how can I set the value of a column in a table according to another column?
    I have a table and when I insert the value in the column content, I want to change this value in the note column with the note, which is generated with pl/sql function (function of string returned if the typed value is in the range).

    I tried to use javascript as
     $('input[name=f02]').live('change', function(){
    if($(this).val()!='1'){
    $('input[name=f03]').val("test")}
    }); 
    for the development of the column note to test if the value typed in the content of the column is not 1, but this code assigns the value to all the lines and I need to set only the specified line.

    Can someone give me a hint in any way to do this if possible?

    Kind regards
    drama9346

    You will need create a process on your page type PLSQL and develop this process "we demand" of the page. In this process, you can run the PLSQL you need. That is to say to retrieve the note value as described in your PC:

    and when I insert the value in the column content, I want to change this value in the note column with the note, which is generated with pl/sql function (function of string returned if the typed value is in the range).

    In this process, you must provide a return value of the call, and you can do this by using htp.p. Example:

    DECLARE
       --putting x01 in a var to simplify
       l_test_var VARCHAR2(200) := apex_application.g_x01;
       l_return VARCHAR2(200);
    BEGIN
       -- a simplistic test
       IF LENGTH(l_test_var) BETWEEN 10 AND 20 THEN
          l_return := 'String is between 10 and 20';
       END IF;
    
       --this will write l_return to the buffer, and the ajax callback will receive this
       htp.p(l_return);
    END;
    

    And the code that I wrote above, which is javascript, would need to go where your current code is that binds to the onchange event. The result should be that, when a change is made to this element, an ajax request is made on the server. When the call is finished, it will be the value returned in the item you want.

  • How to find the second largest in a pl/sql table

    Hello friends,

    I want to find the first and second maximum items in a pl/sql table.

    Here's the code...

    DECLARE
    Max_earnings_type TYPE TABLE IS NUMBER;
    max_earnings_tab max_earnings_type: = max_earnings_type();
    number of v_count: = 0;
    number of v_max_earnings;


    Can someone give me how to find the maximum first max and second in the type of the given table.

    appreciate your help.

    Thank you/kumar

    Published by: kumar73 on October 21, 2010 09:42

    kumar73 wrote:

    When I tried to implement your logic in my application, I get the following error...

    PL/SQL: digital or value error: NULL index key value table

    What happens if the PL/SQL table has NULL values. Question is how you want to handle NULL values. You want to ignore nulls as GROUP BY do? If you want to consider NULL values, you can say if you want to order the NULLS FIRST or NULLS LAST. I guess that logical GROUP BY:

    DECLARE
        TYPE max_earnings_type IS TABLE OF NUMBER;
        TYPE max_earnings_sorted_type IS TABLE OF NUMBER
          INDEX BY BINARY_INTEGER;
        max_earnings_tab        max_earnings_type;
        max_earnings_tab_sorted max_earnings_sorted_type;
    BEGIN
        SELECT  sal + comm
          BULK COLLECT
          INTO  max_earnings_tab
          FROM  emp;
        FOR v_i in 1..max_earnings_tab.count LOOP
          IF max_earnings_tab(v_i) IS NOT NULL
            THEN
              max_earnings_tab_sorted(max_earnings_tab(v_i)) := 1;
          END IF;
        END LOOP;
        DBMS_OUTPUT.PUT_LINE('MAX value in PL/SQL table is ' || nvl(to_char(max_earnings_tab_sorted.last),'NULL'));
        DBMS_OUTPUT.PUT_LINE('Second MAX value in PL/SQL table is ' || nvl(to_char(max_earnings_tab_sorted.prior(max_earnings_tab_sorted.last)),'NULL'));
    END;
    /
    MAX value in PL/SQL table is 2650
    Second MAX value in PL/SQL table is 1900
    
    PL/SQL procedure successfully completed.
    
    SQL> SELECT  sal + comm
      2    FROM  emp;
    
      SAL+COMM
    ----------
    
          1900
          1750
    
          2650
    
          1500
    
      SAL+COMM
    ----------
    
    14 rows selected.
    
    SQL>
    

    SY.

  • ORA-01438: how to find the name of the column?

    Hello

    I'm trying to find the column which is causing ORA-01438 when inserting into a table.

    The insertion is made by a C program that reads from a socket and written in an oracle 10 g database using Oracle Pro * C.

    I tried to identify the column by printing the values (about 250) just before the insert statement is executed, but check these values has been a task heavy and error prone and did not help to correct the mistake (I found a bunch of values which out of reach, but changing these values has not resolved the issue).

    Abandon this idea, I tried to track the session to help
    (1) DBMS_SYSTEM. SET_SQL_TRACE_IN_SESSION,
    (2) DBMS_MONITOR.session_trace_enable/disable and still
    (3) change the context name system set events 10046 trace forever, level 12' and;
    (4) alter system set sql_trace = true scope = mΘmoire;

    DBMS_MONITOR.session_trace_enable only gave me a few tips (the insert statement) in a trace file. But it worked for a simple example of a test database.

    When I try to turn on tracing on the database, where the error occurs, then I'm still not able to set SQL_TRACE in V$ SESSION true, even if no error is returned by the statement "DBMS_MONITOR.session_trace_enable". The value of SQL_TRACE in V$ SESSION does not change and I have no idea why. On the test database, it works fine and I can find the trace file in the user_dump_destination directory.

    Anyone have any suggestions on how to fix this?

    Any help is appreciated.
    Thanks in advance!

    Just check this:

    SQL > conn osama/osama ;
    SQL> create table test as select * from scott.dept ;
    
    SQL> select * from test ;
    
        DEPTNO DNAME          LOC
    ---------- -------------- -------------
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    
    SQL> alter system set events='1438 trace name Errorstack forever,level 10';
    
    SQL> insert into test values (100000000000000000,'osama','JOR');
    insert into test values (100000000000000000,'osama','JOR')
                             *
    ERROR at line 1:
    ORA-01438: value larger than specified precision allowed for this column
    
    In Trace File :
    
    ORA-01438: value larger than specified precision allowed for this column
    Current SQL statement for this session:
    insert into test values (100000000000000000,'osama','JOR')
    
  • How to find the name of the table where the paricular column is common to all the tables...

    Hi all

    any help please...

    I have a lot of tables in the diagram

    Select * from tab; show all tables...

    Now, there is a single table called has columns as name like this, dept, empno, joindate, sal...
    now the description column in table present in so many other tables in the schema above...

    How can I know the names of tables where this 'Description' column shows.

    Note: I use the 10 g version and I do not have DBA privilege on the diagram...

    Thanks in advance
    ASP.

    Are you logged in as owner of these tables? Otherwise (and it seems that you're not), you have privileges on these table? If you do, use:

    SELECT  OWNER,
            TABLE_NAME
      FROM  ALL_TAB_COLUMNS
      WHERE COLUMN_NAME = 'DESIGNATION'
    / 
    

    If you don't have privileges, but you can choose from DBA_TAB_COLUMNS, use:

    SELECT  OWNER,
            TABLE_NAME
      FROM  DBA_TAB_COLUMNS
      WHERE COLUMN_NAME = 'DESIGNATION'
    / 
    

    Otherwise ask your DBA to run it.

    SY.

  • How to find the name of Wi - FI on the account, and if there was a recently with a wi - fi connection

    I have a 'Mini Inspiron' netbook which has been programmed with a built-in WI - FI connection. How can I find out the name of Wi - FI on the account, and if there was a recently with a wi - fi connection, why would it automatically disappear on my netbook and not my phone? Trying to find the normal wi - fi connection called linksys, how to locate or discover what happened?

    Hi JulietHutchinson,

    You can review the article and check if that helps:

    View and connect to available wireless networks

    You may also refer to article and check if it helps:

    Windows wireless and wired network connection problems

  • How to find the name of Os_Process

    Hello

    Database is to have a user name 'TEST '. This db is available in 7-8 developers.nobody is having the test password.
    This user has previously been used by them, but no more.
    The test user connection is requested from their system, but he could not succeed because they do not have the password.

    Run this query
    select os_username,OS_PROCESS ,to_char(timestamp,'MM-DD-YYYY HH24:MI:SS') from dba_audit_trail  where username ='TEST' and to_char(timestamp)=to_char('18-APR-13') group by OS_PROCESS,os_username,username,timestamp order by timestamp;
    
    and getting result as
    OS_USERNAME
    --------------------------------------------------------------------------------
    OS_PROCESS       TO_CHAR(TIMESTAMP,'
    ---------------- -------------------
    VI13948I
    8058             04-18-2013 09:56:59
    
    AS12931I
    13525            04-18-2013 10:11:08
    
    AS12931I
    14609            04-18-2013 10:14:26
    My request is to know how to find what PROCESS name of operating system for the OS_PROCESS id received when I checked the server processes, no existing process with the process ID. (Its because the connection coludnt succeed then couldnot start any process on the server). I checked their systems as well, but no PID is also available with the process ID.

    thanx

    AFAIK, you must query dba_audit_session to see who connected to the database. Dba_audit_trail contains all the audit records, we cannot know if the records that show you are records of connection.

    -----------
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for

  • My Search Bar is goone? nothing to tap on search? What should do? Thank you

    Hello, I use long tome Firfox and very happy.However, since a week I DO NOT HAVE the appers to SEARCH BAR in the page...just no search bar and not google bar I normally have above...for sure all the pages have a... search bar but not when I open fire

  • How can I enable the use of the LinkedIn work initiated for Firefox toolbar?

    I heard through a section of LinkedIn that job seekers can use this tool to the browser through Firefox for free, but I can't figure out how or where to locate and add it.

  • password check failed

    Hi, I have computer laptop hp mini 110 and I can't access my password BIOS more... is possible that I can get it back or you can help me please... add my email is [edited by Moderator] password audit stopped Fatal error... system halted CNU92535R4 yo

  • Download error

    Graphics for Presario CQ60 101AU driver fails to download completely for windows 7(32 bit), sp45230.exe, display error after only 90% download if direct and if downloaded through bitcomet he complete 100% downloaded but again once goes back to 80% an

  • Computer of memory on my hard drive - I already have the basics. How to get free space.

    Original title: I'm out of memory on my hard drive but I have minimum programs, photo and music on it. What else can I remove it? It seems that a lot of programs listed under Add/Remove are installations of service packs or updates. I already deleted