Oracle Stored Procedure export Index

Source: Internet
Author: User

Oracle Stored Procedure export index 1. first create a directory create or replace directory DIR_DUMP as 'd:/Index'; 2. Execute the process in the path 'd: the index.txt file under/Index' is the statement used to export all indexes. Create or replace procedure index_frame is type index_name_type is table of sale % type; v_index_name index_name_type; type index_type_type is table of sale % type; v_index_type index_type_type; type table_name_type is table of sale % type; v_table_name table_name_type; type comment is ref cursor; ind_post ind_post_cur; v_column_name comment % type; v_column_position comment % type; frame_name comment; v_str clob; s_index_type comment % type; status number; begin frame_name: = utl_file.fopen('dir_dump', 'index.txt ', 'w'); select index_name, index_type, table_name bulk collect into v_index_name, v_index_type, v_table_name from user_indexes where index_name not like' % BIN $ % '; for I in 1 .. v_index_name.count loop status: = 1; if v_index_type (I) = 'normal' then s_index_type: = ''; else s_index_type: = v_index_type (I); end if; open ind_post for select column_name, column_position from user_ind_columns where index_name = upper (v_index_name (I) order by column_position asc; v_str: = 'create' | s_index_type | 'index' | v_index_name (I) | 'on' | v_table_name (I) | '('; loop fetch ind_post into v_column_name, v_column_position; if ind_post % notfound then v_str: = v_str | ');'; exit; elsif status = 1 then v_str: = v_str | v_column_name; status: = 0; else v_str: = v_str | ',' | v_column_name; end if; end loop; UTL_FILE.put_line (frame_name, v_str); close ind_post; end loop; UTL_FILE.fclose_all; end;

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.