Oracle queries the database with a value

Source: Internet
Author: User

---restore content starts---

People want to see what data tables in the database, which fields have "HelloWorld" the string, now the database all the tables, views are not directly available, all must go through the loop to access all the data table, all the field columns, and then go to access all the field names. SQL is as follows:

Declare
V_sql VARCHAR2 (2000);
V_count number;
Begin
For xx in (select T.table_name, T.column_name
From user_tab_cols t) loop
Begin
V_sql: = ' SELECT count (*) from ' | | Xx.table_name | |
' WHERE ' | | Xx.column_name | | ' Like '%helloworld% ';
Execute immediate v_sql into V_count;
if (v_count >= 1) Then
Dbms_output.put_line (' results found ' | | Xx.table_name | | ': ' | | xx.column_name| | ' Total ' | | v_count| | ' Article ');
End If;
exception
When others then
Null
End
End Loop;
Dbms_output.put_line (' OK ');
End

Ok.

Oracle queries the database with a value

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.