Иногда лень пересоздавать базу.. Этот скрипт очищает ее полностью от данных (придется генератором еще раз пробежаться)
Код:
declare
crs integer;
ret integer;
stmt varchar2(1000);
firstRus integer;
lastRus integer;
begin
firstRus:=ascii('А');
lastRus:=ascii('Я');
/* delete all users named SUPERMAG_% or with Russian names
the user SUPERMAG isn't deleted here to avoid specification of CASCADE
*/
for rec1 in (select UserName from all_users
where UserName like 'SUPERMAG_%' or
ascii(upper(substr(UserName,1,1))) between firstRus and lastRus
)
loop
stmt:='drop user '||rec1.UserName;
crs:=dbms_sql.open_cursor;
dbms_sql.parse(crs,stmt,DBMS_SQL.NATIVE);
ret:=dbms_sql.execute(crs);
dbms_sql.close_cursor(crs);
end loop;
/* delete all roles named SUPERMAG% or with Russian names
(first letter of Russian role name must be capital or the
role will not be deleted)
*/
for rec2 in (select role from dba_roles
where role like 'SUPERMAG%' or
ascii(substr(Role,1,1)) between firstRus and lastRus
)
loop
stmt:='drop role "'||rec2.role||'"';
crs:=dbms_sql.open_cursor;
dbms_sql.parse(crs,stmt,DBMS_SQL.NATIVE);
ret:=dbms_sql.execute(crs);
dbms_sql.close_cursor(crs);
end loop;
/* drop Supermag and all its tables */
stmt:='drop user Supermag cascade';
crs:=dbms_sql.open_cursor;
dbms_sql.parse(crs,stmt,DBMS_SQL.NATIVE);
ret:=dbms_sql.execute(crs);
dbms_sql.close_cursor(crs);
end;