Home > database >  Rookie help how to reload more efficiency database
Rookie help how to reload more efficiency database

Time:12-27

Background is the fact that the company is doing automated testing, need to restore the database frequently, now use is the stored procedure, query is roughly the change table, and then these tables, copy from another user initial data corresponding to the current user table, complete the data reset, but now the question is, can only use XE version of oracle, so run only up to 2 gb memory, the database can be reset, time is too long, sometimes even need 10 to 15 minutes, want to ask for help in addition to the above I said of the stored procedure method, what is more efficiency way to reset the database to save time?
Attach restore db stored procedure is as follows, hope to have a great god can tell,

The create or replace procedure reloadDB as
Counter number (10);
Sql_statement varchar2 (255);
Cursor cur_test is
The select table_name
The from all_tables
Where the owner='TANGO_DEV'
MODIFICATIONS and table_name not in (' $', 'PLAN_TABLE')
And table_name not in
(select mview_name
The from all_mviews
Where the owner='TANGO_DEV');
The begin
/* no support for foreign key constraints. */

/* truncate and reload all tables that has had changed */
Sql_statement:='SELECT sum (COUNT_MODIFICATIONS) FROM TANGO_DEV. MODIFICATIONS $WHERE TABLE_NAME=: tablename';

For rec_table cur_test in loop
The execute immediate sql_statement
Into counter
Using upper (rec_table table_name);

If the counter & gt; 0 then
The execute immediate 'ALTER TABLE TANGO_DEV.' | | rec_table. Table_name | | 'DISABLE ALL TRIGGERS;

The execute immediate 'TRUNCATE TABLE TANGO_DEV. | | rec_table. Table_name;

The execute immediate 'INSERT/* + append the parallel (4 a) */INTO TANGO_DEV.' | | rec_table. Table_name | | 'a SELECT * FROM SAVE_TANGO_DEV.' | | rec_table. Table_name | | 'NOLOGGING';

The execute immediate 'ALTER TABLE TANGO_DEV.' | | rec_table. Table_name | | 'ENABLE ALL TRIGGERS;
end if;
End loop;

/* delete concurrent entrys */
The execute immediate 'DELETE' | | 'TANGO_DEV' | |
'$where MODIFICATIONS concurrent_entry=1';
Reset/* */modification counter
The execute immediate 'UPDATE' | | 'TANGO_DEV' | |
'MODIFICATIONS $SET COUNT_MODIFICATIONS=0';

commit;
end;
  • Related