declare icount integer:=0; begin select count(1) into icount from user_ind_columns t, user_indexes i where t.index_name = i.index_name and t.table_name = i.table_name and upper(t.table_name) = ‘Txxble‘ and upper(t.INDEX_NAME) =‘PK_Txxble‘; if icount = 1 then execute immediate ‘ALTER TABLE Txxble DROP CONSTRAINT PK_Txxble cascade drop index‘; --删除 --execute immediate ‘DROP INDEX PK_Txxble‘; execute immediate ‘ALTER TABLE Txxble ADD (CONSTRAINT PK_Txxble primary key (c_levelcode) using index tablespace xx_INDEX)‘; --重建 end if; end; /
原文地址:http://ahead51.blog.51cto.com/179590/1658402