LDAP Basics

  

These are my personal notes that I use as a quick help in my work.
You are welcome to read them.

Contents of current page Top-level home page
 
Index  Java Internet Oracle Notes
Linux Basics Web Basics SQL Notes
Informatica Servlets Apache BkpRstore SQL*Plus
Teradata   LDAP Storage PL/SQL
Windows     Tables OEM
UML   Net8 Portal
SQL Server Python perl Performance OLAP
Vmware Visual Basic PHP/MySQL User Mgmt  
Git        
More technical pages here

Contents

 


 

dba_createDB_start_here.bat
sqlplusw.exe /nolog @dba_createDB_creation_scripts.sql
pause
call dba_createDB_go.bat
pause
del dba_createDB_go.bat
  

 

dba_createDB_start_here.sh
#!/bin/sh
sqlplus /nolog @dba_createDB_creation_scripts.sql

 

 

dba_createDB_creation_scripts.sql
-- This script was created by Christopher Thullen - Feb 2005
-- It creates database creation scripts for 9i
-- It does not log onto any database
-- how to implement the pause for the entry of the line in oratab?
-- What about autoextend on? Or ON with maxsize 500M?
--
-- To use this script, copy the scipt dba_createDB_creation_scripts.sql to the server
-- And also copy the file dba_createDB_start_here.bat (for windows)
-- or dba_createDB_start_here.sh (for UNIX)

set doc off echo off
--set termout off feedback off verify off echo off heading off suffix SQL newpage none
set sqlterminator off


-- UNIX
define fs = "/"
-- database for windows, dbs for UNIX
define dbs_database = dbs

-- windows:
define fs = "\"
-- database for windows, dbs for UNIX
define dbs_database = database


define the_SID = "test3"
ACCEPT the_SID char default &the_SID. prompt "Enter SID (default &the_SID.): "

define the_file_prefix = dba_createDB_&the_SID._
--define the_file_prefix = ""

define THE_SERVER = RCGVA01
ACCEPT THE_SERVER char default &THE_SERVER. prompt "Enter the server name (default &THE_SERVER.): "

define CHAR_SET = AL32UTF8
-- *** other possible values: WE8ISO8859P1
ACCEPT CHAR_SET char default &CHAR_SET. prompt "Enter the character set (default &CHAR_SET.): "

define NAT_CHAR_SET = UTF8
-- *** other possible values: AL16UTF16
ACCEPT NAT_CHAR_SET char default &NAT_CHAR_SET. prompt "Enter the national character set (default &NAT_CHAR_SET.): "

define ORA_ADMIN = /u00/app/oracle/admin/&the_SID.
define ORA_ADMIN = C:\oracle\admin\&the_SID.
ACCEPT ORA_ADMIN char default &ora_admin. prompt "Enter location for log files (default &ora_admin.): "

define ORA_DATA1 = /u01/oradata/&the_SID.
define ORA_DATA1 = E:\oracle\oradata\&the_SID.
ACCEPT ORA_DATA1 char default &ORA_DATA1. prompt "Enter the data file location 1 (default &ORA_DATA1.): "

define ORA_DATA2 = /u02/oradata/&the_SID.
define ORA_DATA2 = C:\oracle\oradata\&the_SID.
ACCEPT ORA_DATA2 char default &ORA_DATA2. prompt "Enter the data file location 2 (default &ORA_DATA2.): "

define ORA_ARCH = &ORA_DATA2.&fs.arch
ACCEPT ORA_ARCH char default &ORA_ARCH. prompt "Enter the archive destination (default &ORA_ARCH.): "

define ORACLE_BASE = /u00/app/oracle
define ORACLE_BASE = C:\oracle
ACCEPT ORACLE_BASE char default &ORACLE_BASE. prompt "Enter the ORACLE_BASE (default &ORACLE_BASE.): "

define ORACLE_HOME = /u00/app/oracle/product/9.2.0.1
define ORACLE_HOME = C:\oracle\ora92
ACCEPT ORACLE_HOME char default &ORACLE_HOME. prompt "Enter the ORACLE_HOME (default &ORACLE_HOME.): "

define DEFAULT_PASSWORD = change_on_install


spool &the_file_prefix._cleanup_&the_SID..sh
prompt
prompt echo Remove this entry in the oratab: &the_SID.:&ORACLE_HOME.:Y
prompt
prompt rm &ORACLE_HOME./dbs/orapw&the_SID.
prompt rm &ORACLE_HOME./dbs/spfile&the_SID.
prompt rm -R &ORA_ADMIN.
prompt rm -R &ORA_ARCH.
prompt rm -R &ORA_DATA1.
prompt rm -R &ORA_DATA2.
prompt
spool off

spool &the_file_prefix.&the_SID..sh
prompt #!/bin/ksh
prompt
prompt mkdir &ORA_ADMIN.
prompt mkdir &ORA_ADMIN./bdump
prompt mkdir &ORA_ADMIN./cdump
prompt mkdir &ORA_ADMIN./create
prompt mkdir &ORA_ADMIN./pfile
prompt mkdir &ORA_ADMIN./udump
prompt mkdir &ORA_DATA1.
prompt mkdir &ORA_DATA2.
prompt mkdir &ORA_ARCH.
prompt mkdir &ORACLE_HOME./dbs
prompt
prompt cp &the_file_prefix.&the_SID..sh &ORA_ADMIN./create
prompt cp &the_file_prefix._cleanup_&the_SID..sh &ORA_ADMIN./create
prompt cp &the_file_prefix.CreateDB.sql &ORA_ADMIN./create
prompt cp &the_file_prefix.CreateDBFiles.sql &ORA_ADMIN./create
prompt cp &the_file_prefix.CreateDBCatalog.sql &ORA_ADMIN./create
prompt cp &the_file_prefix.JServer.sql &ORA_ADMIN./create
prompt cp &the_file_prefix.postDBCreation.sql &ORA_ADMIN./create
prompt cp &the_file_prefix.init.ora &ORA_ADMIN./pfile
prompt
prompt export ORACLE_SID=&the_SID.
prompt echo Add this entry in the oratab: &the_SID.:&ORACLE_HOME.:Y
prompt &ORACLE_HOME./bin/orapwd file=&ORACLE_HOME./dbs/orapw&the_SID. password=&DEFAULT_PASSWORD. entries=5
prompt
prompt &ORACLE_HOME./bin/sqlplus /nolog @&ORA_ADMIN./create/&the_file_prefix.CreateDB.sql
prompt &ORACLE_HOME./bin/sqlplus /nolog @&ORA_ADMIN./create/&the_file_prefix.CreateDBFiles.sql
prompt &ORACLE_HOME./bin/sqlplus /nolog @&ORA_ADMIN./create/&the_file_prefix.CreateDBCatalog.sql
prompt &ORACLE_HOME./bin/sqlplus /nolog @&ORA_ADMIN./create/&the_file_prefix.JServer.sql
prompt &ORACLE_HOME./bin/sqlplus /nolog @&ORA_ADMIN./create/&the_file_prefix.postDBCreation.sql
prompt
spool off


spool &the_file_prefix.cleanup_&the_SID..bat
prompt
prompt &ORACLE_HOME.\bin\ORADIM -SHUTDOWN -SID &the_SID. -SHUTMODE a
prompt pause Is OracleService&the_SID. stopped?
prompt
prompt &ORACLE_HOME.\bin\ORADIM -DELETE -SID &the_SID.
prompt type &ORACLE_HOME.\database\OraDim.Log
prompt pause Is the service OracleService&the_SID. removed (see services)?
prompt
prompt del &ORACLE_HOME.\database\PWD&the_SID..ora
prompt del &ORACLE_HOME.\database\SPFILE&the_SID..ora
prompt del &ORA_ADMIN.\bdump\*
prompt del &ORA_ADMIN.\cdump\*
prompt del &ORA_ADMIN.\create\*
prompt del &ORA_ADMIN.\pfile\*
prompt del &ORA_ADMIN.\udump\*
prompt del &ORA_ADMIN.\*
prompt del &ORA_DATA1.\*
prompt del &ORA_DATA2.\*
prompt del &ORA_ARCH.\*
prompt
prompt rmdir &ORA_ARCH.
prompt rmdir &ORA_DATA1.
prompt rmdir &ORA_DATA2.
prompt rmdir &ORA_ADMIN.\bdump
prompt rmdir &ORA_ADMIN.\cdump
prompt rmdir &ORA_ADMIN.\pfile
prompt rmdir &ORA_ADMIN.\udump
prompt rmdir &ORA_ADMIN.\create
prompt rmdir &ORA_ADMIN.
prompt
-- just in case the files were previously created in the default area
prompt del &ORACLE_BASE.\admin\&the_SID.\*
prompt del &ORACLE_BASE.\oradata\&the_SID.\*
prompt rmdir &ORACLE_BASE.\admin\&the_SID.
prompt rmdir &ORACLE_BASE.\oradata\&the_SID.
--
prompt pause
prompt
spool off

spool &the_file_prefix.main.bat
prompt
prompt mkdir &ORA_ADMIN.\bdump
prompt mkdir &ORA_ADMIN.\cdump
prompt mkdir &ORA_ADMIN.\create
prompt mkdir &ORA_ADMIN.\pfile
prompt mkdir &ORA_ADMIN.\udump
prompt mkdir &ORA_DATA1.
prompt mkdir &ORA_DATA2.
prompt mkdir &ORA_ARCH.
prompt mkdir &ORACLE_HOME.\database
prompt
prompt copy &the_file_prefix.main.bat &ORA_ADMIN.\create
prompt copy &the_file_prefix.cleanup_&the_SID..bat &ORA_ADMIN.\create
prompt copy &the_file_prefix.CreateDB.sql &ORA_ADMIN.\create
prompt copy &the_file_prefix.CreateDBFiles.sql &ORA_ADMIN.\create
prompt copy &the_file_prefix.CreateDBCatalog.sql &ORA_ADMIN.\create
--prompt copy &the_file_prefix.JServer.sql &ORA_ADMIN.\create
prompt copy &the_file_prefix.postDBCreation.sql &ORA_ADMIN.\create
prompt copy &the_file_prefix.init.ora &ORA_ADMIN.\pfile
prompt
prompt set ORACLE_SID=&the_SID.
prompt &ORACLE_HOME.\bin\ORADIM -NEW -SID &the_SID. -INTPWD &DEFAULT_PASSWORD. -MAXUSERS 5 -STARTMODE a -PFILE &ORA_ADMIN.\pfile\init.ora
--oradim /?
--oradim -NEW -SID <sid> -INTPWD <pw> -MAXUSERS 5 -STARTMODE a|m -PFILE <file>
--oradim -DELETE -SID <sid>
--oradim -STARTUP -SID <sid> [-PFILE <filename>]
--oradim -SHUTDOWN -SID <sid> -SHUTMODE a | i | n
prompt type &ORACLE_HOME.\database\OraDim.Log
prompt dir &ORACLE_HOME.\database\PWD&the_SID..ora
prompt pause Is OracleService&the_SID. created and the password file created?
prompt
--prompt &ORACLE_HOME.\bin\orapwd.exe file=&ORACLE_HOME.\database\PWD&the_SID..ora password=&DEFAULT_PASSWORD. entries=5
--prompt pause
prompt
prompt &ORACLE_HOME.\bin\sqlplus /nolog @&ORA_ADMIN.\create\&the_file_prefix.CreateDB.sql
prompt pause
prompt &ORACLE_HOME.\bin\sqlplus /nolog @&ORA_ADMIN.\create\&the_file_prefix.CreateDBFiles.sql
prompt &ORACLE_HOME.\bin\sqlplus /nolog @&ORA_ADMIN.\create\&the_file_prefix.CreateDBCatalog.sql
--prompt &ORACLE_HOME.\bin\sqlplus /nolog @&ORA_ADMIN.\create\&the_file_prefix.JServer.sql
prompt &ORACLE_HOME.\bin\sqlplus /nolog @&ORA_ADMIN.\create\&the_file_prefix.postDBCreation.sql
prompt
spool off

spool dba_createDB_go.bat
prompt pause About to remove database &the_SID.
prompt call &the_file_prefix.cleanup_&the_SID..bat
prompt pause About to create database &the_SID.
prompt call &the_file_prefix.main.bat
prompt pause
spool off


spool &the_file_prefix.CreateDB.sql

prompt connect SYS/&DEFAULT_PASSWORD. as SYSDBA
prompt set echo on
prompt spool &ORA_ADMIN.&fs.create&fs.CreateDB.log
prompt startup nomount pfile="&ORA_ADMIN.&fs.pfile&fs.&the_file_prefix.init.ora";
prompt CREATE DATABASE &the_SID.
prompt USER SYS IDENTIFIED BY &DEFAULT_PASSWORD. USER SYSTEM IDENTIFIED BY &DEFAULT_PASSWORD.
prompt MAXINSTANCES 1 MAXLOGHISTORY 1 MAXLOGFILES 5 MAXLOGMEMBERS 3 MAXDATAFILES 100
prompt DATAFILE '&ORA_DATA1.&fs.system01.dbf' SIZE 250M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
prompt EXTENT MANAGEMENT LOCAL
prompt DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '&ORA_DATA1.&fs.temp01.dbf' SIZE 40M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE 500M
prompt UNDO TABLESPACE UNDOTBS1 DATAFILE '&ORA_DATA1.&fs.undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE 500M
prompt CHARACTER SET &CHAR_SET.
prompt NATIONAL CHARACTER SET &NAT_CHAR_SET.
prompt LOGFILE GROUP 1 ('&ORA_DATA1.&fs.redo01.log', '&ORA_ADMIN.&fs.redo01.log') SIZE 102400K,
prompt GROUP 2 ('&ORA_DATA1.&fs.redo02.log', '&ORA_ADMIN.&fs.redo02.log') SIZE 102400K,
prompt GROUP 3 ('&ORA_DATA1.&fs.redo03.log', '&ORA_ADMIN.&fs.redo03.log') SIZE 102400K;
prompt spool off
prompt exit;
prompt
spool off


-- *** What about max log history?

spool &the_file_prefix.CreateDBFiles.sql

prompt connect SYS/&DEFAULT_PASSWORD. as SYSDBA
prompt set echo on
prompt spool &ORA_ADMIN.&fs.create&fs.CreateDBFiles.log
prompt CREATE TABLESPACE INDX LOGGING DATAFILE '&ORA_DATA1.&fs.indx01.dbf'
prompt SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE 500M
prompt EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO AUTOALLOCATE;

prompt CREATE TABLESPACE TOOLS LOGGING DATAFILE '&ORA_DATA1.&fs.tools01.dbf'
prompt SIZE 10M REUSE AUTOEXTEND ON NEXT 320K MAXSIZE 500M
prompt EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO AUTOALLOCATE;

prompt CREATE TABLESPACE USR_DATA LOGGING DATAFILE '&ORA_DATA1.&fs.usr_data01.dbf'
prompt SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE 500M
prompt EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO AUTOALLOCATE;

prompt spool off
prompt exit;
prompt
spool off


spool &the_file_prefix.CreateDBCatalog.sql

prompt connect SYS/&DEFAULT_PASSWORD. as SYSDBA
prompt set echo on
prompt spool &ORA_ADMIN.&fs.create&fs.CreateDBCatalog.log
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.catalog.sql;
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.catexp7.sql;
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.catblock.sql;
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.catproc.sql;
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.catoctk.sql;
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.owminst.plb;
prompt connect SYSTEM/&DEFAULT_PASSWORD.
prompt @&ORACLE_HOME.&fs.sqlplus&fs.admin&fs.pupbld.sql;
prompt connect SYSTEM/&DEFAULT_PASSWORD.
prompt set echo on
prompt spool &ORA_ADMIN.&fs.create&fs.sqlPlusHelp.log
prompt @&ORACLE_HOME.&fs.sqlplus&fs.admin&fs.help&fs.hlpbld.sql helpus.sql;
prompt spool off
prompt spool off
prompt exit;
prompt
spool off


--spool &the_file_prefix.JServer.sql
--
--prompt connect SYS/&DEFAULT_PASSWORD. as SYSDBA
--prompt set echo on
--prompt spool &ORA_ADMIN.&fs.create&fs.JServer.log
--prompt @&ORACLE_HOME.&fs.javavm&fs.install&fs.initjvm.sql;
--prompt @&ORACLE_HOME.&fs.xdk&fs.admin&fs.initxml.sql;
--prompt @&ORACLE_HOME.&fs.xdk&fs.admin&fs.xmlja.sql;
--prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.catjava.sql;
--prompt spool off
--prompt exit;
--prompt
--spool off


spool &the_file_prefix.postDBCreation.sql

prompt connect SYS/&DEFAULT_PASSWORD. as SYSDBA
prompt set echo on
prompt spool &ORA_ADMIN.&fs.create&fs.postDBCreation.log
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.utlrp.sql;
prompt shutdown ;
prompt startup mount pfile="&ORA_ADMIN.&fs.pfile&fs.&the_file_prefix.init.ora";
prompt alter database archivelog;
prompt alter database open;
prompt alter system archive log start;
prompt shutdown ;
prompt connect SYS/&DEFAULT_PASSWORD. as SYSDBA
prompt set echo on
prompt spool &ORA_ADMIN.&fs.create&fs.postDBCreation.log
prompt create spfile='&ORACLE_HOME.&fs.&dbs_database.&fs.spfile&the_SID..ora' FROM pfile='&ORA_ADMIN.&fs.pfile&fs.&the_file_prefix.init.ora';
prompt startup ;
prompt exit;
prompt
spool off

 


spool &the_file_prefix.init.ora

prompt #
prompt # names
prompt db_domain=&THE_SERVER.
prompt db_name=&the_SID.
prompt instance_name=&the_SID.
prompt #
prompt

prompt #
prompt # arch
prompt log_archive_dest_1='LOCATION=&ORA_ARCH. MANDATORY'
prompt log_archive_format=&the_SID._%s_%t.arc
prompt log_archive_start=true
prompt #
prompt

prompt #
prompt # block size
prompt db_block_size=4096
-- *** other possible values: 2048, 4096, 8192, 16384
prompt #
prompt

prompt #
prompt # memory
prompt db_cache_size=25165824
-- *** other possible values:
prompt db_file_multiblock_read_count=16
-- *** other possible values:
prompt java_pool_size=0
-- *** other possible values: 104857600
prompt large_pool_size=8388608
-- *** other possible values:
prompt shared_pool_size=104857600
-- *** other possible values:
prompt pga_aggregate_target=25165824
-- *** other possible values:
prompt sort_area_size=524288
-- *** other possible values:
prompt #
prompt

prompt #
prompt # log locations
prompt background_dump_dest=&ORA_ADMIN.&fs.bdump
prompt core_dump_dest=&ORA_ADMIN.&fs.cdump
prompt timed_statistics=TRUE
prompt user_dump_dest=&ORA_ADMIN.&fs.udump
prompt #
prompt

prompt #
prompt # control files
prompt control_files= "&ORA_ADMIN.&fs.control01.ctl"
prompt control_files= "&ORA_DATA1.&fs.control02.ctl"
prompt control_files= "&ORA_DATA2.&fs.control03.ctl"
prompt #
prompt

prompt #
prompt # undo
prompt undo_management=AUTO
prompt undo_retention=10800
-- *** other possible values:
prompt undo_tablespace=UNDOTBS1
prompt #
prompt

prompt #
prompt # other
prompt open_cursors=300
prompt job_queue_processes=10
prompt
prompt aq_tm_processes=1
prompt compatible=9.2.0.0.0
prompt
prompt hash_join_enabled=TRUE
prompt query_rewrite_enabled=FALSE
prompt star_transformation_enabled=FALSE
prompt processes=150
prompt job_queue_processes = 4
prompt
prompt fast_start_mttr_target=300
prompt
prompt remote_login_passwordfile=EXCLUSIVE
prompt audit_trail = none
prompt
spool off

set sqlterminator ";"


prompt
prompt . @dba_createDB_creation_scripts.sql
prompt
prompt
prompt . To clean up an old creation:
prompt . - stop the database (abort)
prompt . - run the file &the_file_prefix.cleanup_&the_SID..bat
prompt
prompt
prompt . The next step is to run the script
prompt . --> &the_file_prefix.&the_SID..sh (for UNIX)
prompt . remember: chmod u+x &the_file_prefix.&the_SID..sh
prompt . --> &the_file_prefix.main.bat (for windows)
prompt . These scripts create the database
prompt . After the creation, change the default passwords for SYS and SYSTEM
prompt . (currently "&DEFAULT_PASSWORD.")
prompt . The parameters (especially for memory) may need tuning
prompt . Add "&the_SID." to "tnsnames.ora" AND to "listener.ora"
prompt

pause Press ENTER to continue (and exit the script), ^C to stay in sqlplus

exit

  

 

 

dba_createDB_after_create.sql
prompt
SET echo off
SET heading off
SET verify off
set feedback on

accept the_db char prompt "Enter database name: "

define pw = change_on_install
ACCEPT pw CHAR default &pw. PROMPT "Current password for SYSTEM on &the_db (default &pw.): " HIDE

connect system/&pw.@&the_db.

COLUMN global_name NEW_VALUE the_db
SELECT lower(global_name) FROM global_name;
prompt The database is &the_db
--DEFINE the_db = ampersand database_connection
ACCEPT the_db CHAR default &the_db. PROMPT "SID alias in lower case (default &the_db.): "

ACCEPT pw CHAR PROMPT "New password for SYS and SYSTEM on &the_db : " HIDE
prompt The new password is &pw
pause Press enter to continue (^C to stop)

ALTER USER SYSTEM IDENTIFIED BY &pw.;

prompt User TRACESVR not changed
PROMPT ALTER USER TRACESVR IDENTIFIED BY &pw; ;

ALTER USER DBSNMP IDENTIFIED BY DBSNMP;

ALTER USER SYS IDENTIFIED BY &pw.;

ALTER USER OUTLN IDENTIFIED BY &pw.;


set verify on

prompt connect system/&pw.@&the_db.
connect system/&pw.@&the_db.

DEFINE default_tablespace = USERS

-- **** Create user SCOTT

CREATE USER "SCOTT" IDENTIFIED BY "TIGER"
DEFAULT TABLESPACE "&default_tablespace"
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT;

GRANT CREATE SESSION TO "SCOTT";

-- **** Create user data_owner
CREATE USER data_owner IDENTIFIED BY &pw.
DEFAULT TABLESPACE "USERS"
TEMPORARY TABLESPACE TEMP
QUOTA UNLIMITED ON "USERS" ;
GRANT connect TO data_owner;
ALTER USER data_owner DEFAULT ROLE all;

-- ************** Modify existing users

alter user "OUTLN"
DEFAULT TABLESPACE &default_tablespace
TEMPORARY TABLESPACE TEMP;

alter user "TRACESVR"
DEFAULT TABLESPACE &default_tablespace
TEMPORARY TABLESPACE TEMP;

alter user "DBSNMP"
DEFAULT TABLESPACE &default_tablespace
TEMPORARY TABLESPACE TEMP;

-- Job for switching logs
connect sys/&pw.@&the_db. as sysdba

grant select on sys.v_$log to system;
grant sysoper to edp;

connect system/&pw.@&the_db.

grant alter system to system;

CREATE OR REPLACE PROCEDURE SWITCH_LOG (max_delay IN INTEGER) IS
v_cursor INTEGER; -- cursor variable
v_return INTEGER; -- resultat von dbms_sql.execute.
v_statement VARCHAR(255); -- statement to execute
last_switch INTEGER; -- how long since last logswitch?
BEGIN
-- get last log switch in minutes
SELECT (sysdate-first_time)*(24*60) INTO last_switch FROM v$log WHERE status='CURRENT';

-- if last log switch is older than max_delay, switch log
IF last_switch > max_delay THEN
v_statement := 'ALTER SYSTEM ARCHIVE LOG CURRENT';
v_cursor := dbms_sql.open_cursor;
dbms_sql.parse(v_cursor,v_statement,sys.dbms_sql.native);
v_return := dbms_sql.execute(v_cursor);
dbms_sql.close_cursor(v_cursor);
END IF;

EXCEPTION
WHEN OTHERS THEN
dbms_sql.close_cursor(v_cursor);
dbms_output.put_line(SUBSTR(SQLERRM,1,200));

END SWITCH_LOG;
/

show errors;

prompt Modifier le parametre d'initialisation set job_queue_processes = 4
alter system set job_queue_processes = 4 scope=spfile;

prompt
prompt VARIABLE jobno number; ;
prompt BEGIN
prompt DBMS_JOB.SUBMIT(:jobno,
prompt 'system.SWITCH_LOG(1/48);',
prompt SYSDATE, 'SYSDATE + 1/48'); ;
prompt COMMIT; ;
prompt END; ;
prompt /
prompt PRINT jobno
prompt
pause Execute the lines above to create the job (later). Press ENTER to continue.

SET VERIFY OFF