Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 933929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:54:47+00:00 2026-05-15T20:54:47+00:00

How to select all records,that may contain specific value that is known, without referring

  • 0

How to select all records,that may contain specific value that is known, without referring to specific column in SQL expression?

For instance, i know,that some unknown column holds value ‘xxx’ and there are many columns and records in table.

Thank you.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:54:47+00:00Added an answer on May 15, 2026 at 8:54 pm

    So, you want to do a Google-like free text search over your database. This can be done but the performance will be Teh Suck! Google is fast because it has indexes on its indexes, duplicate data stores and generally optimizes everything for precisely this kind of search.

    Anyway, here is a proof of concept using dynamic SQL and the Oracle data dictionary. Note that I restrict the columns to the type of data I want to search for i.e. strings.

    SQL> set serveroutput on size unlimited
    SQL> declare
      2      dummy varchar2(1);
      3  begin
      4      for r in ( select table_name, column_name from user_tab_cols
      5                 where data_type in ('VARCHAR2', 'CHAR', 'CLOB') )
      6      loop
      7          begin
      8              execute immediate 'select null from '||r.table_name
      9                      ||' where '||r.column_name||' like ''%&search_value%'' '
     10                      ||' and rownum = 1'
     11                 into dummy;
     12              dbms_output.put_line('Found it in >>>'
     13                     ||r.table_name||'.'||r.column_name);
     14          exception
     15              when others then
     16                  -- bad practice ahoy!
     17                  null;
     18          end;
     19      end loop;
     20  end;
     21  /
    Enter value for search_value: MAISIE
    old   9:                ||' where '||r.column_name||' like ''%&search_value%'' '
    new   9:                ||' where '||r.column_name||' like ''%MAISIE%'' '
    Found it in >>>T23.NAME
    
    PL/SQL procedure successfully completed.
    
    SQL>
    

    A more robust implementation might need to handle case, whole words, etc. If you’re on 10g or higher then regular expressions could be useful, but combining regex and dynamic SQL is an, er, interesting prospect.

    I repeat that performance is going to be Teh Suck! on a large data set. It is virtually impossible to tune, because we cannot index every column, and certainly not to support LIKE or similar fuzzy matches. An alternative approach would be to use XQuery to generate an XML representation of your data and then use Text to index it. Maintaining such a repository would be overhead, but the effort would be a sound investment if you need this functionality of a regular basis, especially in a production environment.


    We can conduct a broader search across all the tables we have privileges on by using all_tab_cols instead.

    for r in ( select owner, table_name, column_name from all_tab_cols
                       where data_type in ('VARCHAR2', 'CHAR', 'CLOB') )
    

    Obviously we need to prefix the owning schema in the generated statement.

    execute immediate 'select null from '||r.owner||'.'||r.table_name
                           ||' where '||r.column_name||' like ''%
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may look complicated, but I am really just trying to select all records
I have three tables I'd like to join in a way that produces all
This may be a tough one for you all, if it is even possible
I hope somebody may be able to point out where i'm going wrong here
Synopsis I've got a query with a WHERE clause that contains a condition that
I'm using LINQ to SQL for a .NET MVC app. In my db i
I've been using Linq-to-SQL for quite awhile and it works great. However, lately I've
What I got so far: It all begins with an HTML form which prompts
This may be complicated to explain. I have set up a timesheet system where
I feel like I am fighting against the current when I develop ASP.NET Webform

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.