























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























Create Tablespace: SQL> create tablespace admintbs datafile '$ORACLE_BASE/oradata/ORCL/datafile/admintbs_1.dbf' size 50m; --Tablespace name is admintbs and datafile is admintbs1.dbs while size is 50 mb. SQL> DROP TABLESPACE
The below query is helpful to know the status of the groups: Sql> select * from v$log; To switch a log file: Sql> alter system switch logfile; By default Redolog files contains of three groups, 2 members each. Each memeber is replica to the other member, and placed in different location from the other so that in case of disk failure we might have the redo log files. Adding the redo log groups: Sql>alter database add logfile group 4 '/u01/app/oracle/oradata/ORCL/redo04.log' size 10m; Dropping the existing redo log groups: Sql>alter database drop logfile group 4; Clearing a redo log file: Sql>alter database clear logfile group 3; To Rename or Move log file: 1: Shu Immediate; 2: Startup mount; 3: Then move or rename file physical file and then enter this sql query: Sql> alter database rename file '/u01/app/oracle/oradata/ORCL/redo04.log' to '/u01/app/oracle/oradata/redo04.log'; Database altered. ` alter database mount;
1: Shut Database down 2: Copy controlfile from existant location. 3: Create new dir and paste controlfile in it. 4: Startup database and Alter System: SQL> ALTER SYSTEM SET control_files = '/u01/app/oracle/oradata/ORCL/controlfile/o1_mf_k8g9n5x1_.ctl', '/u01/app/oracle/fast_recovery_area/ORCL/controlfile/o1_mf_k8g9n5y8_.ctl', '/u01/app/oracle/third_control_file/o1_mf_k8g9n5y8_.ctl' SCOPE=SPFILE; SQL> select * from v$controlfile;
To archive a filled redo log group manually, connect with administrator privileges. Ensure that the database is mounted but not open. Use the ALTER SYSTEM statement with the ARCHIVE LOG clause to manually archive filled redo log files. SQL> ALTER SYSTEM ARCHIVE LOG ALL;
Adjusting the Number of Archiver Processes The LOG_ARCHIVE_MAX_PROCESSES initialization parameter specifies the number of ARCn processes that the database initially invokes. The default is two processes.The LOG_ARCHIVE_MAX_PROCESSES parameter is dynamic, and can be changed using the ALTER SYSTEM statement. The database must be mounted but not open. SQL> ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=3;
The following example shows a setting of LOG_ARCHIVE_FORMAT: ALTER SYSTEM SET LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' SCOPE=SPFILE; %t=thread %s=sequence number %r= reset log id
To Change archivelog Location: Create the new archive location:
oracle@oracle]$ mkdir - p /u01/app/oracle/archivelogs/ SQL> connect / as sysdba Change the destination of archive logs: SQL> alter system set log_archive_dest_n='LOCATION=/u01/app/oracle/archivelogs' scope=both; IF you want to multiplex archive logs then use: SQL> alter system set log_archive_dest_1='LOCATION=/u01/app/oracle/archivelogs' log_archive_dest_2='LOCATION=/u02/app/oracle/archivelogs' scope=both;
If the database is in NOARCHIVELOG it must be switched to ARCHIVELOG mode. SQL> shutdown immediate SQL> startup mount SQL> alter database archivelog; SQL> alter database open; Flashback must be enabled before any flashback operations are performed. SQL> alter database flashback on; With flashback enabled the database can be switched back to a previous point-in-time or SCN without the need for a manual incomplete recovery. In the following example a table is created, the database is then flashbacked to a time before the table was created. SQL> CREATE TABLE test(id number(9)); Flashback the database to previous SCN, to before the test table was created. To Flashback the Database, database must be in mount state. SQL> shutdown immediate SQL> startup mount SQL> flashback database to SCN(scn number); SQL> alter database open resetlogs; SQL> desc test; Table or view does't exist. To check previous SCN:
SQL > select * from v$ flashback_database_log; To flashback in timestamp: SQL> flashback table test to timestamp TO_TIMESTAMP('2022- 06 - 30 13:02:20', 'YYYY-MM-DD HH24:MI:SS'); Some other variations of the flashback database command include the following: flashback database to timestamp {my_date}; flashback database to before timestamp {my_date}; flashback database to scn {my_scn}; flashback database to before scn {my_scn};
RESTORE POINTS A restore point is a name assigned to a system change number (SCN) in Oracle. An SCN is a number that uniquely identifies each new change to an Oracle database; this number is incremented whenever users commit a new transaction to the database. SQL> create restore point before_changes; Existing restore points can be displayed using the V$RESTORE_POINT view: SQL> select name from v$restore_point; RESULT: NAME
BEFORE_CHANGES
[oracle@NEW-SERVER ~]$ rman target / connected to target database (not started) RMAN> startup nomount; RMAN> restore controlfile from '/u01/rman/Controlback_20210329_0kvqv13g_1_1'; RMAN> alter database mount; RMAN> report schema; RMAN> catalog start with '/u01/rman/'; Restore the Database : RMAN>
run { allocate channel ch1 device type disk; restore database; switch datafile all; switch tempfile all; release channel ch1; } Recover the Database : RMAN> list backup of archivelog all; RMAN> run { allocate channel ch1 device type disk; recover database until sequence 41; release channel ch1; } OR run { restore database;