Declare rows integer;
Begin
-- Delete a table
Execute immediate 'select count (*) from user_all_tables where upper (table_name) = upper (''bm _ ratiodata_temp '') 'into rows;
If rows> 0 then
Execute immediate 'drop table bm_ratiodata_temp ';
End if;
-- Add a column
Execute immediate 'select count (*) from all_tab_columns where table_name = ''sjdwzt ''and column_name = ''isvirtual ''' into rows;
If rows <1 then
Execute immediate 'alter table sjdwzt add isvirtual int null ';
End if;
-- Modify a table column
Execute immediate 'select count (*) from all_tab_columns where table_name = ''sjfagroup ''and column_name = ''leibie ''' into rows;
If rows <1 then
Execute immediate 'alter table sjfagroup alter column leibie varchar (30 )';
End if;
-- Delete a foreign key
Execute immediate 'select count (*) from user_constraints where table_name = ''test2' and constraint_name = ''for _ test''' into rows;
If rows> 0 then
Execute immediate 'alter table Test2 drop constraint for_test ';
End if;
-- Checklist Name:
Select count (*) from user_tables where table_name = table name (uppercase );
-- Check the field name:
Select count (*) from user_tab_columns where table_name = 'bm _ effect' and column_name = 'benchmarkid'
Select * From user_cons_columns; -- all columns
-- Query the primary key
Select * From user_constraints where constraint_type = 'p' and constraint_name = 'pk _ bm_condition roup 'and table_name = 'test'
-- Search for Indexes
Select * From dba_indexes where index_name = 'idx _ grouping roup'
-- Create an index
-- Create index idx_sjobjectcollection_objecttype on sjobjectcollection (objecttype)
-- Cascade table Deletion
-- Drop table bm_ratio_type cascade constraints;
End;