How users can effectively use the data dictionary

Source: Internet
Author: User
Tags chr comments functions log sql query
Data Oracle Data Dictionary is one of the important parts of database, it is produced with the database, which changes with the change of the database, and embodies some tables and views under the SYS user. The data dictionary name is an uppercase English character. The     data dictionary contains the user information, the user's permission information, all the data object information, the table constraint condition, the statistical Analysis database view and so on.  We can't modify the information in the data dictionary by hand.  Most of the time, the average Oracle user doesn't know how to use it effectively. Dictionary The name and interpretation of all data dictionary tables, it has a synonym dict    dict_column all data dictionary table field names and explanations        If we want to query the index-related data dictionary, we can use the following SQL statement:        Sql>select * from dictionary where InStr ( Comments, ' index ') >0;        if we want to know the detailed meaning of each field name in the User_indexes table, you can use the following SQL statement:         sql>select column_name,comments from dict_columns where table_name= ' user_indexes ';         and so on, you can easily know the detailed name and explanation of the data dictionary without looking at Oracle's other documentation.         Below is a list of the query usage methods for some Oracle users ' common data dictionaries by category.         A, user     view the default table space for the current user     Sql>select username, Default_tablespace from User_users View the role of the current user Sql>select * from User_Role_privs; View the current user's system permissions and table-level permissions Sql>select * from User_sys_privs; Sql>select * from user_tab_privs;    II, tables         View all tables under User      Sql>select * from user_tables;            view table with the name containing log characters & nbsp;   sql>select object_name,object_id from user_objects         where InStr (object_name, ' LOG ') >0;        view when a table was created     Sql>select Object_name,created from User_objects where Object_name=upper (' &table_name ');         View the size of a table     sql>select sum (bytes)/(1024*1024) as "size (M)" from User_segments          where Segment_name=upper (' &table_name ');        View the tables placed in Oracle's memory area     Sql>select Table_name,cache from User_tables where InStr (Cache, ' Y ') >0;         Index         View index number and category     Sql>select Index_name,index_type,table_ Name from user_indexes-table_name;        view indexed fields     sql> SELECT * from User_ind_columns where Index_name=upper (' &index_name ');        View the size of the index     sql>select sum (bytes)/(1024*1024) as "size (M)" from User_segments         where Segment_name=upper (' &index_name ');        IV, serial number          View serial number, Last_number is current value     Sql>select * from user_sequences;         v. View         View the name of the view     Sql>select View_name from user_views;        View the SELECT statement for creating a view     sql>set view_ Name,text_length from user_views;    sql>set long 2000; Description: Can be based on the view's Text_leThe Ngth value sets the size of the set long     sql>select text from user_views where View_name=upper (' &view_name ');         vi. synonyms         view synonyms name     sql> SELECT * FROM user_synonyms;        VII constraint conditions         View constraints on a table     sql>select constraint_name, Constraint_type,search_condition, R_constraint_name         from user_constraints WHERE table_name = UPPER (' &table_name ');   & nbsp     sql>select c.constraint_name,c.constraint_type,cc.column_name      from User_constraints c,user_cons_columns cc    where C.owner = Upper (' &table_owner ') and c.table_name = Upper (' &table_name ')     and C.owner = Cc.owner and c.constraint_name = cc.constraint_name     ORDER by cc.position;                VIII, storage functions and procedures         viewing the status of functions and procedures     sql> Select Object_name,status from user_objects where object_type= ' FUNCTION ';    sql>select object_name , status from User_objects where object_type= ' PROCEDURE ';        View source   of functions and procedures    sql>select text from All_source where Owner=user and Name=upper (' &plsql_name ');    & nbsp;   IX, triggers         view triggers     set long 50000;     Set heading off;    set pagesize 2000;    select    ' Create or Replace Trigger "' | |             Trigger_name | | '"' || Chr (10) | |      Decode (substr (Trigger_type, 1, 1),              ' A ', ' after ', ' B ', ' before ', ' I ', ' INSTEAD of ') | |                   chr (10) | |      Triggering_event | | Chr (10) | |      ' On ' | | Table_owner | | '"."' ||            table_name | | '"' || Chr (10) | |      Decode (InStr (Trigger_type, ' each ROW '), 0, null,                 ' for each ROW ') | | Chr (a),     trigger_body    from user_triggers;   

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.