Does the oracle view use a table?

Source: Internet
Author: User

Cause:

1. incomplete documentation

2. Years of forgetting

3. Employee resignation

Result: A table (XZF_CASE_DISCUSS) does not know what the table is used in the view. Is it a waste table? You cannot view the view one by one!

Method: Of course not required. oracle provides a variety of data registration forms and views, and all user objects can be queried. For example, if we want to query a view, we will involve a table: user_views.

select * from user_views;

The TEXT field stores the statements generated by the view. You only need to traverse these statements and check whether the statements contain the target table name to find out where the table is used.

select instr(text,'XZF_CASE_DISCUSS',1,1) from user_views;
This seems to solve the problem, but I suddenly found that the TEXT field is of the LONG type, so we can only accept the error result:

I checked the data and found that the LONG type is not easy to operate. It is a data type not recommended by oracle. Although it is still in use, it is estimated that it will expire soon. Here is an improvement method:

Create TABLE testBak (col1 clob);  insert into testBak select text from user_views;
In this way, the TEXT field of the LONG type is converted to the clob type, so we are familiar with the clob type. You can directly use the instr function to operate it.

select instr(col1,'XZF_CASE_DISCUSS',1,1) from  testBak 

It can be seen that all records are 0, indicating that the XZF_CASE_DISCUSS table has not been used in all views. Although it cannot be determined that the table is a waste table, it can be proved that there is no such thing in the view.

Summary: oracle is the most powerful relational database on the planet. If you have an idea, there is nothing impossible. As long as you are willing to move your mind and look up information, the solution will certainly be available.


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.