Skip to content

ASMCMD-08102: no connection to ASM; command requires ASM to run

[oracle@mazar ~]$ asmcmd
Connected to an idle instance.
ASMCMD> ls -L +DATA
ASMCMD-08102: no connection to ASM; command requires ASM to run

Solution :
We need to Set ASM Instance Oracle home path 
[oracle@mazar ~]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid
[oracle@mazar ~]$ export PATH=/u01/app/oracle/product/11.2.0/grid/bin
[oracle@mazar ~]$ export ORACLE_SID=+ASM
[oracle@mazar ~]$ asmcmd

ASMCMD> ls -L +DATA/DBASM/DATAFILE
SYSAUX.257.753010705
SYSTEM.256.753010703
TESTTBS.275.753248961
UNDOTBS1.258.753010705
USERS.259.753010705
ASMCMD>

Transport an entire database to a Different platform

Here I’m go to demonstrate How do we transport entire database to a different platform.

We can use “convert database” command to move an entire database to different operating system But we need to check out both Operating system having same endian format.

Here I’m go to Transport Database From Linux 32 bit machine to Windows 7 64 bit machine.

Source Database :

Database Name –> dbasm

OS –>Linux 32 Bit,

Endian Format :

SQL> col platform_name for a40
SQL> set linesize 100
SQL> select a.platform_id,a.platform_name,b.endian_format
  2  from v$database a,v$transportable_platform b where b.platform_id(+) = a.platform_id;

PLATFORM_ID PLATFORM_NAME                            ENDIAN_FORMAT
----------- ---------------------------------------- --------------
         10 Linux IA (32-bit)                        Little

Target Database :

OS --> Windows 7 64 Bit

Endian Format (I checked currently running on another database of this OS).
SQL> set linesize 100
SQL> col platform_name for a40
SQL> select a.platform_id,a.platform_name,b.endian_format
2 from v$database a,v$transportable_platform b where b.platform_id(+) = a.platform_id;

PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- ---------------------------------------- --------------
12 Microsoft Windows x86 64-bit Little

Step 1 : Create One Tablespace and add a table and some data

SQL> select name from v$database;

NAME---------DBASM

SQL> create tablespace testtbs datafile '+DATA' size 50m;

Tablespace created.

SQL> create user testme identified by testme default tablespace testtbs;

User created.

SQL> grant connect,resource to testme;

Grant succeeded.

SQL> conn testme/testmeConnected.SQL> create table employee(name varchar2(20));

Table created.

SQL> insert into employee values('azar');

1 row created.

SQL> insert into employee values('kareem');

1 row created.

SQL> insert into employee values('jabar');

1 row created.

SQL> insert into employee values('ajmal');

1 row created.

SQL> commit;

Commit complete.

Step 2: Check Datafile

NAME
--------------------------------------------------------------------------------
+DATA/dbasm/datafile/system.256.753010703
+DATA/dbasm/datafile/sysaux.257.753010705
+DATA/dbasm/datafile/undotbs1.258.753010705
+DATA/dbasm/datafile/users.259.753010705
+DATA/dbasm/datafile/testtbs.275.753248961

Step 3:

             Take RMAN BACKUP

Step 4:
The source database is eligible for transporting to the destination operatingsystem platform by executing the dbms_tdb.check_db procedure.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  636100608 bytes
Fixed Size                  1338392 bytes
Variable Size             222299112 bytes
Database Buffers          406847488 bytes
Redo Buffers                5615616 bytes
Database mounted.
SQL> alter database open read only;

Database altered.

SQL> set serveroutput on
SQL> declare
  2  db_ready boolean;
  3  begin
  4  db_ready := dbms_tdb.check_db('Microsoft Windows x86 64-bit',dbms_tdb.skip_readonly);
  5  end;
  6  /

PL/SQL procedure successfully completed.

For External Table.

SQL> declare
  2  external boolean;
  3  begin
  4  external := dbms_tdb.check_external;
  5  end;
  6  /
The following directories exist in the database:
SYS.ORACLE_OCM_CONFIG_DIR, SYS.DATA_PUMP_DIR, SYS.XMLDIR

PL/SQL procedure successfully completed.

Step 5: Convert Database . Database should be in Read Only mode.

[oracle@mazar ~]$ rlwrap rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Jun 8 05:28:46 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DBASM (DBID=2095353796)

RMAN> convert database new database 'dbasm'
2> transport script '/u01/temp/dbasm_script'
3> to platform 'Microsoft Windows x86 64-bit'
4> db_file_name_convert '+DATA/dbasm/datafile/' '/u01/temp/';

Starting conversion at source at 08-JUN-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=33 device type=DISK

Directory SYS.ORACLE_OCM_CONFIG_DIR found in the database
Directory SYS.DATA_PUMP_DIR found in the database
Directory SYS.XMLDIR found in the database

User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00001 name=+DATA/dbasm/datafile/system.256.753010703
converted datafile=/u01/temp/system.256.753010703
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:59
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00002 name=+DATA/dbasm/datafile/sysaux.257.753010705
converted datafile=/u01/temp/sysaux.257.753010705
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00003 name=+DATA/dbasm/datafile/undotbs1.258.753010705
converted datafile=/u01/temp/undotbs1.258.753010705
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00005 name=+DATA/dbasm/datafile/testtbs.275.753248961
converted datafile=/u01/temp/testtbs.275.753248961
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00004 name=+DATA/dbasm/datafile/users.259.753010705
converted datafile=/u01/temp/users.259.753010705
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
Edit init.ora file /u01/app/oracle/product/11.2.0/dbhome_1/dbs/init_00mebgha_1_0.ora. This PFILE will be used to create the database on the target platform
Run SQL script /u01/temp/dbasm_script on the target platform to create database
To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target platform
To change the internal database identifier, use DBNEWID Utility
Finished conversion at source at 08-JUN-11

RMAN>

Step 6:
Now Move the “dbasm_script”,pfile –“init_00mebgha_1_0.ora”, and all db file from “/u01/temp/”
to Windows platform using External Hard Disk.
Now you need to edit the “Init” file and “dbasm_script” appropriate your windows directory struture where you want restore
all datafiles.
i just Edited My init Ora file like Below

Step 7: copied init_00mebgha_1_0.ora and renamed it initDBASM.ora –>
C:\app\Azar\product\11.2.0\dbhome_1\dbs\initDBASM.ora
Edit initDBASM.ora

# Please change the values of the following parameters:

  db_create_file_dest      = "C:\app\Azar\product\11.2.0\dbhome_1\dbs\dbasm"

  db_recovery_file_dest    = "C:\app\Azar\product\11.2.0\dbhome_1\dbs\dbasm"

  db_recovery_file_dest_size= 8078229504

  audit_file_dest          = "C:\app\Azar\admin\dbasm\adump"

  db_name                  = "DBASM"

# Please review the values of the following parameters:

# __oracle_base            = "C:\app\Azar"

  __shared_pool_size       = 209715200

  __large_pool_size        = 4194304

  __java_pool_size         = 4194304

  __streams_pool_size      = 4194304

  __sga_target             = 637534208

  __db_cache_size          = 406847488

  __shared_io_pool_size    = 0

  remote_login_passwordfile= "EXCLUSIVE"

  db_domain                = ""

  dispatchers              = "(PROTOCOL=TCP) (SERVICE=dbasmXDB)"

  __pga_aggregate_target   = 213909504

# The values of the following parameters are from source database:

  processes                = 150

  sga_target               = 637534208

  db_block_size            = 8192

  compatible               = "11.2.0.0.0"

  log_archive_format       = "%t_%s_%r.dbf"

  undo_tablespace          = "UNDOTBS1"

  audit_trail              = "OS"

  open_cursors             = 300

  pga_aggregate_target     = 211812352

# diagnostic_dest          = "C:\app\Azar"

Step 8: Copied dbasm_script.sql file –> C:\app\dbasm_script.sql
Edited below like

STARTUP NOMOUNT PFILE='C:\app\Azar\product\11.2.0\dbhome_1\dbs\initDBASM.ora'

-- Create SPFILE
CREATE SPFILE FROM PFILE = 'C:\app\Azar\product\11.2.0\dbhome_1\dbs\initDBASM.ora';

STARTUP FORCE NOMOUNT
CREATE CONTROLFILE REUSE SET DATABASE "DBASM" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 SIZE 50M BLOCKSIZE 512,
  GROUP 2 SIZE 50M BLOCKSIZE 512,
  GROUP 3 SIZE 50M BLOCKSIZE 512
DATAFILE
  'C:\app\Azar\oradata\dbasm\system.256.753010703',
  'C:\app\Azar\oradata\dbasm\sysaux.257.753010705',
  'C:\app\Azar\oradata\dbasm\undotbs1.258.753010705',
  'C:\app\Azar\oradata\dbasm\users.259.753010705',
  'C:\app\Azar\oradata\dbasm\testtbs.275.753248961'
CHARACTER SET WE8MSWIN1252
;

-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;

-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE 
     SIZE 20971520  AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
-- End of tempfile additions.
--

set echo off
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prompt * Your database has been created successfully!
prompt * There are many things to think about for the new database. Here
prompt * is a checklist to help you stay on track:
prompt * 1. You may want to redefine the location of the directory objects.
prompt * 2. You may want to change the internal database identifier (DBID) 
prompt *    or the global database name for this database. Use the 
prompt *    NEWDBID Utility (nid).
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SHUTDOWN IMMEDIATE 
STARTUP UPGRADE 
@@ ?/rdbms/admin/utlirp.sql 
SHUTDOWN IMMEDIATE 
STARTUP
-- The following step will recompile all PL/SQL modules.
-- It may take serveral hours to complete.
@@ ?/rdbms/admin/utlrp.sql 
set feedback 6;

Step 9:

Copied DBF files to “C:\app\Azar\oradata\dbasm\”

Step 10: Create new instance and password file

C:\Windows\system32>oradim -new -sid dbasm
Instance created.

C:\Windows\system32>orapwd file=c:\app\Azar\product\11.2.0\dbhome_1\database\PWDdbasm.ora password=Test123

Step 11: Run the script file

C:\Windows\system32>set ORACLE_SID=dbasm

C:\Windows\system32>sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 8 14:31:52 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Enter user-name: sys/Test123 as sysdba
Connected to an idle instance.

SQL> @c:\app\dbasm_script.sql
ORACLE instance started.

Total System Global Area  634679296 bytes
Fixed Size                  2178416 bytes
Variable Size             184550032 bytes
Database Buffers          440401920 bytes
Redo Buffers                7548928 bytes

File created.
ORACLE instance started.

Total System Global Area  634679296 bytes
Fixed Size                  2178416 bytes
Variable Size             184550032 bytes
Database Buffers          440401920 bytes
Redo Buffers                7548928 bytes

Control file created.

Database altered.

ALTER TABLESPACE TEMP ADD TEMPFILE
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Your database has been created successfully!
* There are many things to think about for the new database. Here
* is a checklist to help you stay on track:
* 1. You may want to redefine the location of the directory objects.
* 2. You may want to change the internal database identifier (DBID)
*    or the global database name for this database. Use the
*    NEWDBID Utility (nid).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Database closed.
Database dismounted.
ORACLE instance shut down.
ORACLE instance started.

Total System Global Area  634679296 bytes
Fixed Size                  2178416 bytes
Variable Size             184550032 bytes
Database Buffers          440401920 bytes
Redo Buffers                7548928 bytes
Database mounted
Database opened.

DOC>   utlirp.sql completed successfully. All PL/SQL objects in the
DOC>   database have been invalidated.
DOC>
DOC>   Shut down and restart the database in normal mode and run utlrp.sql to
DOC>   recompile invalid objects.
DOC>#######################################################################
DOC>#######################################################################
DOC>#
SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP
ORACLE instance started.

Total System Global Area  634679296 bytes
Fixed Size                  2178416 bytes
Variable Size             184550032 bytes
Database Buffers          440401920 bytes
Redo Buffers                7548928 bytes
Database mounted.
Database opened.
SQL> -- The following step will recompile all PL/SQL modules.
SQL> -- It may take serveral hours to complete.
SQL> @@ ?/rdbms/admin/utlrp.sql
SQL> Rem
SQL> Rem $Header: utlrp.sql 24-jul-2003.10:06:51 gviswana Exp $
SQL> Rem
SQL> Rem utlrp.sql
SQL> Rem
SQL> Rem Copyright (c) 1998, 2003, Oracle Corporation.  All rights reserved.
SQL> Rem
SQL> Rem    NAME
SQL> Rem         utlrp.sql - Recompile invalid objects
SQL> Rem

Warning: XDB now invalid, could not find xdbconfig
ORDIM INVALID OBJECTS: CODE_SEQUENCE110_T - 6 - 13
ORDIM INVALID OBJECTS: CODE_SEQUENCE112_COLL - 6 - 13
ORDIM INVALID OBJECTS: CODE_SQ111_T - 6 - 13
ORDIM INVALID OBJECTS: ORD_DICOM_HEADER114_T - 6 - 13
ORDIM INVALID OBJECTS: MEDIA_STORAGE_SOP_CLASS116_T - 6 - 13
ORDIM INVALID OBJECTS: MEDIA_STORAGE_SOP_INSTA117_T - 6 - 13
ORDIM INVALID OBJECTS: TRANSFER_SYNTAX_UID118_T - 6 - 13
ORDIM INVALID OBJECTS: IMPLEMENTATION_CLASS_UI119_T - 6 - 13
ORDIM INVALID OBJECTS: IMPLEMENTATION_VERSION_120_T - 6 - 13
ORDIM INVALID OBJECTS: SOURCE_APPLICATION_ENTI121_T - 6 - 13
ORDIM INVALID OBJECTS: FILE_META_HEADER115_T - 6 - 13
ORDIM INVALID OBJECTS: NAME124_T - 6 - 13
ORDIM INVALID OBJECTS: ID125_T - 6 - 13
ORDIM INVALID OBJECTS: BIRTH_DATE126_T - 6 - 13
ORDIM INVALID OBJECTS: SEX127_T - 6 - 13
ORDIM INVALID OBJECTS: PATIENT123_T - 6 - 13
ORDIM INVALID OBJECTS: INSTANCE_UID129_T - 6 - 13
ORDIM INVALID OBJECTS: DATE130_T - 6 - 13
ORDIM INVALID OBJECTS: TIME132_T - 6 - 13
ORA-25153: Temporary Tablespace is Empty
ORA-01403: no data found
FAILED CHECK FOR PACKAGE BODY WWV_FLOW_API

PL/SQL procedure successfully completed.

Now Database successfully created.

Step 12: Check the new database

SQL> select status from v$instance;

STATUS
------------
OPEN

SQL> select name from v$database;

NAME
---------
DBASM

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
C:\APP\AZAR\ORADATA\DBASM\SYSTEM.256.753010703
C:\APP\AZAR\ORADATA\DBASM\SYSAUX.257.753010705
C:\APP\AZAR\ORADATA\DBASM\UNDOTBS1.258.753010705
C:\APP\AZAR\ORADATA\DBASM\USERS.259.753010705
C:\APP\AZAR\ORADATA\DBASM\TESTTBS.275.753248961

SQL> select * from v$tempfile;

no rows selected

SQL> ALTER TABLESPACE TEMP ADD TEMPFILE SIZE 20971520  AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;

Tablespace altered.

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
C:\APP\AZAR\PRODUCT\11.2.0\DBHOME_1\DBS\DBASM\DBASM\DATAFILE\O1_MF_TEMP_6YYR9B7D
_.TMP

SQL> conn testme/testme
Connected.
SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
EMPLOYEE                       TABLE

SQL> select * from employee;

NAME
--------------------
azar
kareem
jabar
ajmal

SQL>

Ref :

http://download.oracle.com/docs/cd/E11882_01/backup.112/e10642/rcmxplat.htm#BRADV89986

 

 

No termcap nor curses library found while configuring rlwrap on OEL

While configuring rlwrap on my Oracle Enterprise Linux,I faced some below errors

[root@mazar rlwrap-0.30]# ./configure

———————————–
———————————–
———————————–
configure: checking for pty ranges…
checking for tgetent… no
checking for tgetent in -lcurses… no
checking for tgetent in -lncurses… no
checking for tgetent in -ltermcap… no
configure: WARNING: No termcap nor curses library found
checking for readline in -lreadline… no
configure: error:

Solution : We need to install below rpm packages

[root@mazar tmp]# rpm -Uvh libtermcap-devel-2.0.8-46.1.i386.rpm
warning: libtermcap-devel-2.0.8-46.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing… ########################################### [100%]
1:libtermcap-devel ########################################### [100%]
[root@mazar tmp]# rpm -Uvh readline-devel-5.1-3.el5.i386.rpm
warning: readline-devel-5.1-3.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing… ########################################### [100%]
1:readline-devel ########################################### [100%]
[root@mazar tmp]#

 

After Installed, Now I Can able to configure rlwrap.

[root@mazar rlwrap-0.30]# ./configure
checking build system type… i686-pc-linux-gnu
checking host system type… i686-
config.status: creating doc/rlwrap.man
config.status: creating distribution/rlwrap.spec
config.status: creating config.h
config.status: executing depfiles commands

Now do:
make (or gmake) to build rlwrap
make check for instructions how to test it
make install to install it
pc-linux-gnu

ORA-01565: error in identifying file /dbs/spfile@.ora

When we’re going to create pfile from spfile while spfile running on ASM instance, We can face the below errors,

SQL> create pfile=’/u01/inittest.ora’ from spfile;
create pfile=’/u01/inittest.ora’ from spfile
*
ERROR at line 1:
ORA-01565: error in identifying file ‘?/dbs/spfile@.ora’
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

Solution :

We need to give ASM path of SPFILE.

SQL> create pfile=’/u01/inittest.ora’ from spfile=’+DATA/dbasm/spfiledbasm.ora’;

File created.

Can we create additional database for Oracle Express Edition?

Can we create new additional database for Oracle Expression Edition? Because No DBCA available in express edition, However we can create database using manual script.

We can follow way for normal database creation manual steps only…

Consider new Database Name is “XETEST”

Step 1:  Create suitable directory for new database.

like below

C:\oraclexe\app\oracle\admin\XETEST
  • adump
  • dpdump
  • pfile
C:\oraclexe\app\oracle\oradata\XETEST

Step 2: Create new instance for new database

       C:\Windows\system32>oradim -new -sid xetest
         Instance created.

Step 3 : Create password file for new database

C:\Windows\system32>orapwd file=C:\oraclexe\app\oracle\product\11.2.0\server\database\PWDXETEST.ora password=sysxe

Step 4 : Create New pfile like below

xe.__db_cache_size=117440512
xe.__java_pool_size=4194304
xe.__large_pool_size=8388608
xe.__oracle_base='C:\oraclexe\app\oracle'#ORACLE_BASE set from environment
xe.__pga_aggregate_target=188743680
xe.__sga_target=566231040
xe.__shared_io_pool_size=92274688
xe.__shared_pool_size=335544320
xe.__streams_pool_size=0
*.audit_file_dest='C:\oraclexe\app\oracle\admin\XETEST\adump'
*.compatible='11.2.0.0.0'
*.control_files='C:\oraclexe\app\oracle\oradata\XETEST\control.dbf'
*.db_name='XETEST'
*.DB_RECOVERY_FILE_DEST_SIZE=10G
*.DB_RECOVERY_FILE_DEST='C:\oraclexe\app\oracle\flash_recovery_area'
*.diagnostic_dest='C:\oraclexe\app\oracle'###########################################
*.dispatchers='(PROTOCOL=TCP) (SERVICE=XETESTXDB)'
*.job_queue_processes=4
*.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=AZAR-PC.ace-ins.com)(PORT=1522))'
*.open_cursors=300
*.os_authent_prefix=''
*.pga_aggregate_target=180M
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=20
*.sga_target=540M
*.shared_servers=4
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'

Step 5: Stratup nomount stage db using new pfile

.
C:\Windows\system32>SET ORACLE_SID=XETEST

C:\Windows\system32>sqlplus

SQL*Plus: Release 11.2.0.2.0 Beta on Sun May 22 15:23:42 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Enter user-name: / as sysdba
Connected to an idle instance.

SQL> startup nomount pfile='d:\temp\initXETEST.ora';
ORACLE instance started.

Total System Global Area  564957184 bytes
Fixed Size                  1384956 bytes
Variable Size             171970052 bytes
Database Buffers          385875968 bytes
Redo Buffers                5726208 bytes

Step 6: Create Database Script  like below

create database XETEST
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
  GROUP 1 'D:\temp\redolog\REDO01.LOG'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 'D:\temp\redolog\REDO02.LOG'  SIZE 50M BLOCKSIZE 512
DATAFILE'C:\oraclexe\app\oracle\oradata\XETEST\SYSTEM.DBF' size 100m autoextend on
sysaux datafile 'C:\oraclexe\app\oracle\oradata\XETEST\SYSAUX.DBF' size 100m autoextend on
undo tablespace undotbs1 datafile  'C:\oraclexe\app\oracle\oradata\XETEST\UNDOTBS1.DBF' size 100m autoextend on
CHARACTER SET AL32UTF8
;

Step 7: After created it, you can run at sql prompt


SQL> @D:\temp\create.sql

Database created.

Step 8: Now database was created, Check Instance status & Version

SQL> select status from v$instance;

STATUS
------------
OPEN

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Beta
PL/SQL Release 11.2.0.2.0 - Beta
CORE    11.2.0.2.0      Production
TNS for 32-bit Windows: Version 11.2.0.2.0 - Beta
NLSRTL Version 11.2.0.2.0 - Production

SQL>
The above newly created database is Express edition version.
And also RUN
SQL> @C:\oraclexe\app\oracle\product\11.2.0\server\rdbms\admin\catalog.sql

SQL> @C:\oraclexe\app\oracle\product\11.2.0\server\rdbms\admin\catproc.sql

Oracle 11g R1/R2 Real Application Clusters Essentials Book live now

One of My Best Advisor Mr.Syed Jaffar Hussain book has been released. Now It’s on live. It should be useful for who willing to learn more things about RAC High Availability.

You can buy it from follow publication URL.

http://www.packtpub.com/oracle-11g-r1-r2-real-application-clusters-essentials/book#in_detail

What you will learn from this book :

  • Learn how to administer, implement, and manage Oracle 11g RAC environments for real world deployments
  • Discover the key architectural design and installation techniques required to successfully deploy Oracle 11g RAC
  • Effectively manage the complex 11g Clusterware, using key troubleshooting tips and techniques
  • Successfully implement database creation methods, manage the Oracle RAC database and handle workload in your RAC environment efficiently
  • Appropriately plan your backup and recovery strategy
  • Know when and how to upgrade your Oracle RAC environment effectively
  • Discover how to deploy Oracle 11g RAC with complex standard-off-the-shelf systems like Oracle EBS
  • Understand new key features for Oracle 11g R1/R2 RAC and ASM

RMAN-06091: no channel allocated for maintenance (of an appropriate type)

When I tried to delete obsolete backup, it shows following error.

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of delete command at 05/16/2011 14:41:39
RMAN-06091: no channel allocated for maintenance (of an appropriate type)


Solution :

Please refer
Encountered RMAN-03002 and RMAN-06091 when Deleting Obsolete Backups (Doc ID 567555.1)

Recover truncate table using RMAN tablespace point in time recovery

Here I’m go to demonstrate How do we recover truncate table using RMAN tablespace point in time recovery.

I hope This post may very user friendly for you without confusion 🙂

Step 1:  Create tablespace and allocate one user for this tablespace 

SQL> create tablespace rmantbs datafile 'c:\temp\rmnatbs01.dbf' size 100m;

Tablespace created.

SQL> create user rmantbs identified by rmantbs default tablespace rmantbs;

User created.

SQL> grant connect,resource to rmantbs;

Grant succeeded.

SQL> grant read,write on directory data_pump_dir to rmantbs;

Grant succeeded.

 

Step 2: Create another one tablespace and allocated another new user which one checking data lost will happen or not after TBPITR recovery done.

SQL> create tablespace rmantest datafile 'c:\temp\rmantest01.dbf' size 50m;

Tablespace created.

SQL> create user rmantest identified by rmantest default tablespace rmantest;

User created.

SQL> grant connect,resource to rmantest;

Grant succeeded.

Step 3: Create two table and insert few rows

SQL> set time on
21:12:02 SQL> conn rmantbs/rmantbs
Connected.
21:12:25 SQL> create table employee(empno number,empname varchar2(20));

Table created.

21:13:20 SQL> insert into employee values(001,'azar');

1 row created.

21:13:36 SQL> insert into employee values(002,'jabar');

1 row created.

21:13:45 SQL> insert into employee values(003,'kareem');

1 row created.

21:13:54 SQL> insert into employee values(004,'ajmal');

1 row created.

21:14:08 SQL> commit;

Commit complete.

21:14:11 SQL> create table empcity(cityname varchar2(20));

Table created.

21:14:41 SQL> insert into empcity values('riyadh');

1 row created.

21:14:53 SQL> commit;

Commit complete.

Step 4: create anothe one table for rmantest user which allocated rmantest tablespace.

:55 SQL> conn rmantest/rmantest
Connected.
21:15:01 SQL> create table a(empno number);

Table created.

21:15:14 SQL> insert into a values(001);

1 row created.

21:15:24 SQL> insert into a values(002);

1 row created.

21:15:29 SQL> insert into a values(003);

1 row created.

21:15:39 SQL> insert into a values(004);

1 row created.

21:15:42 SQL> commit;

Commit complete.

Step 5: Switch logfile

21:15:44 SQL> conn / as sysdba
Connected.
21:15:53 SQL> alter system switch logfile;

System altered.

Step 6: Backup database with archivelog

RMAN> backup database plus archivelog;
Starting backup at 25-APR-11
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=2 RECID=1 STAMP=749251241
input archived log thread=1 sequence=3 RECID=2 STAMP=749332191
input archived log thread=1 sequence=4 RECID=3 STAMP=749333774
input archived log thread=1 sequence=5 RECID=4 STAMP=749333841
input archived log thread=1 sequence=6 RECID=5 STAMP=749333984
input archived log thread=1 sequence=7 RECID=6 STAMP=749338753
input archived log thread=1 sequence=8 RECID=7 STAMP=749342576
input archived log thread=1 sequence=9 RECID=8 STAMP=749342688
input archived log thread=1 sequence=10 RECID=9 STAMP=749417043
input archived log thread=1 sequence=11 RECID=10 STAMP=749423783
input archived log thread=1 sequence=12 RECID=11 STAMP=749423884
channel ORA_DISK_1: starting piece 1 at 25-APR-11
channel ORA_DISK_1: finished piece 1 at 25-APR-11
piece handle=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\BACKUPSET\2011_04_25\O1_MF_
ANNNN_TAG20110425T211805_6VCGPYCN_.BKP tag=TAG20110425T211805 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 25-APR-11

Starting backup at 25-APR-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=C:\APP\AZAR\ORADATA\RMANTBS\SYSTEM01.DBF
input datafile file number=00002 name=C:\APP\AZAR\ORADATA\RMANTBS\SYSAUX01.DBF
input datafile file number=00005 name=C:\TEMP\RMNATBS01.DBF
input datafile file number=00006 name=C:\TEMP\RMANTEST01.DBF
input datafile file number=00003 name=C:\APP\AZAR\ORADATA\RMANTBS\UNDOTBS01.DBF
input datafile file number=00004 name=C:\APP\AZAR\ORADATA\RMANTBS\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 25-APR-11
channel ORA_DISK_1: finished piece 1 at 25-APR-11
piece handle=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\BACKUPSET\2011_04_25\O1_MF_
NNNDF_TAG20110425T211821_6VCGQGL8_.BKP tag=TAG20110425T211821 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55
Finished backup at 25-APR-11

Starting backup at 25-APR-11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=13 RECID=12 STAMP=749424018
channel ORA_DISK_1: starting piece 1 at 25-APR-11
channel ORA_DISK_1: finished piece 1 at 25-APR-11
piece handle=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\BACKUPSET\2011_04_25\O1_MF_
ANNNN_TAG20110425T212018_6VCGV2GZ_.BKP tag=TAG20110425T212018 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-APR-11

Starting Control File and SPFILE Autobackup at 25-APR-11
piece handle=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\AUTOBACKUP\2011_04_25\O1_MF
_S_749424019_6VCGV4KX_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 25-APR-11

RMAN>

Step 7:  Note Current Timestamp before truncate table

21:16:23 SQL> select current_timestamp from dual;

CURRENT_TIMESTAMP
---------------------------------------------------------------------------
25-APR-11 09.21.30.293000 PM +03:00 21:21:30 SQL> conn rmantbs/rmantbs
Connected.
21:21:49 SQL> select * from employee;

     EMPNO EMPNAME
---------- --------------------
         1 azar
         2 jabar
         3 kareem
         4 ajmal

21:22:13 SQL> truncate table employee;

Table truncated.

Step 8: Insert some few rows for another one table which is usefull for whether data loss or not and also How do we preserve these data.

21:25:16 SQL> insert into empcity values('chennai');

1 row created.

21:27:14 SQL> insert into empcity values('trichy');

1 row created.

21:27:22 SQL> insert into empcity values('dammam');

1 row created.

21:27:33 SQL> conn rmantest/rmantest
Connected.
21:27:44 SQL> insert into a values(005);

1 row created.

21:27:53 SQL> commit;

Commit complete.

Step 9: Before you done tbpitr, you must check Determine and Resolved Dependencies

21:27:59 SQL> conn / as sysdba
Connected.
21:35:14 SQL> SELECT * FROM sys.ts_pitr_check WHERE(ts1_name = 'RMANTBS' AND ts2
_name != 'RMANTBS')  OR (ts1_name != 'RMANTBS' AND ts2_name = 'RMANTBS');

no rows selected

Step 10 : Determine Which Objects Will Not Be Recovered

For objects in tablespaces involved with the TSPITR, you’ll lose any transactions that were

created prior to the point to which you restore. If you need to preserve objects created after

the time to which you are going to restore, then you’ll need to use the Datapump or Export utility to save them.

After you have performed TSPITR, then you can import these objects.

21:36:47 SQL> SELECT owner, name, tablespace_name FROM ts_pitr_objects_to_be_dro
pped WHERE tablespace_name ='RMANTBS' AND creation_time > to_date('25-APR-11 09.
21.30','DD-MON-RRRR HH24:MI:SS');

OWNER                          NAME
------------------------------ ------------------------------
TABLESPACE_NAME
------------------------------
RMANTBS                        EMPLOYEE
RMANTBS

RMANTBS                        EMPCITY
RMANTBS

More details about See metalink ID TSPITR:How to check dependency of the objects and identifying objects that will be lost after TSPITR [ID 304308.1]

Step 11: Export the above two tables data for safe purpose.But Here Employee table not need, only EMPCITY table enough for export, However I exported two tables

C:\Users\Azar>expdp rmantbs/rmantbs directory=data_pump_dir dumpfile=datatbs.dmp
 logfile=datatbs.log tables=employee,empcity

Export: Release 11.2.0.1.0 - Production on Mon Apr 25 21:38:33 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "RMANTBS"."SYS_EXPORT_TABLE_01":  rmantbs/******** directory=data_pump_
dir dumpfile=datatbs.dmp logfile=datatbs.log tables=employee,empcity
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "RMANTBS"."EMPCITY"                         5.062 KB       4 rows
. . exported "RMANTBS"."EMPLOYEE"                            0 KB       0 rows
Master table "RMANTBS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for RMANTBS.SYS_EXPORT_TABLE_01 is:
  C:\APP\AZAR\ADMIN\RMANTBS\DPDUMP\DATATBS.DMP
Job "RMANTBS"."SYS_EXPORT_TABLE_01" successfully completed at 21:38:53

 

Step 12: Recover Truncate table using TBPITR

RMAN> recover tablespace RMANTBS until time "to_date('25-APR-11 21:21:30','DD-MO
N-RRRR HH24:MI:SS')" auxiliary destination 'C:\TEMP\auxxtest';

Starting recover at 25-APR-11
using channel ORA_DISK_1
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified
 point-in-time

List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1

Creating automatic instance, with SID='mbfF'
initialization parameters used for automatic instance:
db_name=RMANTBS
db_unique_name=mbfF_tspitr_RMANTBS
compatible=11.2.0.0.0
db_block_size=8192
db_files=200
sga_target=280M
processes=50
db_create_file_dest=C:\TEMP\auxxtest
log_archive_dest_1='location=C:\TEMP\auxxtest'
#No auxiliary parameter file used
starting up automatic instance RMANTBS

Oracle instance started

Total System Global Area     292278272 bytes

Fixed Size                     2175128 bytes
Variable Size                100667240 bytes
Database Buffers             184549376 bytes
Redo Buffers                   4886528 bytes
Automatic instance created
Running TRANSPORT_SET_CHECK on recovery set tablespaces
contents of Memory Script:
{
# set requested point in time
set until  time "to_date('25-APR-11 21:21:30','DD-MON-RRRR HH24:MI:SS')";
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script

executing command: SET until clause

Starting restore at 25-APR-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=60 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece C:\APP\AZAR\FLASH_RECOVERY_ARE
A\RMANTBS\AUTOBACKUP\2011_04_25\O1_MF_S_749424019_6VCGV4KX_.BKP
channel ORA_AUX_DISK_1: piece handle=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\AUT
OBACKUP\2011_04_25\O1_MF_S_749424019_6VCGV4KX_.BKP tag=TAG20110425T212019
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=C:\TEMP\AUXXTEST\RMANTBS\CONTROLFILE\O1_MF_6VCJBORG_.CTL
Finished restore at 25-APR-11

sql statement: alter database mount clone database

sql statement: alter system archive log current

sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;

contents of Memory Script:
{
# set requested point in time
set until  time "to_date('25-APR-11 21:21:30','DD-MON-RRRR HH24:MI:SS')";
plsql <<<-- tspitr_2
declare
  sqlstatement       varchar2(512);
  offline_not_needed exception;
  pragma exception_init(offline_not_needed, -01539);
begin
  sqlstatement := 'alter tablespace '||  'RMANTBS' ||' offline immediate';
  krmicd.writeMsg(6162, sqlstatement);
  krmicd.execSql(sqlstatement);
exception
  when offline_not_needed then
    null;
end; >>>;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile  1 to new;
set newname for clone datafile  3 to new;
set newname for clone datafile  2 to new;
set newname for clone tempfile  1 to new;
set newname for datafile  5 to
 "C:\TEMP\RMNATBS01.DBF";
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  1, 3, 2, 5;
switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

sql statement: alter tablespace RMANTBS offline immediate

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME
renamed tempfile 1 to C:\TEMP\AUXXTEST\RMANTBS\DATAFILE\O1_MF_TEMP_%U_.TMP in co
ntrol file

Starting restore at 25-APR-11
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to C:\TEMP\AUXXTEST\RMANTBS\DAT
AFILE\O1_MF_SYSTEM_%U_.DBF
channel ORA_AUX_DISK_1: restoring datafile 00003 to C:\TEMP\AUXXTEST\RMANTBS\DAT
AFILE\O1_MF_UNDOTBS1_%U_.DBF
channel ORA_AUX_DISK_1: restoring datafile 00002 to C:\TEMP\AUXXTEST\RMANTBS\DAT
AFILE\O1_MF_SYSAUX_%U_.DBF
channel ORA_AUX_DISK_1: restoring datafile 00005 to C:\TEMP\RMNATBS01.DBF
channel ORA_AUX_DISK_1: reading from backup piece C:\APP\AZAR\FLASH_RECOVERY_ARE
A\RMANTBS\BACKUPSET\2011_04_25\O1_MF_NNNDF_TAG20110425T211821_6VCGQGL8_.BKP
channel ORA_AUX_DISK_1: piece handle=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\BAC
KUPSET\2011_04_25\O1_MF_NNNDF_TAG20110425T211821_6VCGQGL8_.BKP tag=TAG20110425T2
11821
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:26
Finished restore at 25-APR-11

datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=749425659 file name=C:\TEMP\AUXXTEST\RMANTBS\D
ATAFILE\O1_MF_SYSTEM_6VCJCP1B_.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=749425659 file name=C:\TEMP\AUXXTEST\RMANTBS\D
ATAFILE\O1_MF_UNDOTBS1_6VCJCP58_.DBF
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=749425659 file name=C:\TEMP\AUXXTEST\RMANTBS\D
ATAFILE\O1_MF_SYSAUX_6VCJCP53_.DBF

contents of Memory Script:
{
# set requested point in time
set until  time "to_date('25-APR-11 21:21:30','DD-MON-RRRR HH24:MI:SS')";
# online the datafiles restored or switched
sql clone "alter database datafile  1 online";
sql clone "alter database datafile  3 online";
sql clone "alter database datafile  2 online";
sql clone "alter database datafile  5 online";
# recover and open resetlogs
recover clone database tablespace  "RMANTBS", "SYSTEM", "UNDOTBS1", "SYSAUX" del
ete archivelog;
alter clone database open resetlogs;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  1 online

sql statement: alter database datafile  3 online

sql statement: alter database datafile  2 online

sql statement: alter database datafile  5 online

Starting recover at 25-APR-11
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 13 is already on disk as file C:\APP\AZA
R\FLASH_RECOVERY_AREA\RMANTBS\ARCHIVELOG\2011_04_25\O1_MF_1_13_6VCGV25P_.ARC
archived log for thread 1 with sequence 14 is already on disk as file C:\APP\AZA
R\FLASH_RECOVERY_AREA\RMANTBS\ARCHIVELOG\2011_04_25\O1_MF_1_14_6VCJBXKV_.ARC
archived log file name=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\ARCHIVELOG\2011_0
4_25\O1_MF_1_13_6VCGV25P_.ARC thread=1 sequence=13
archived log file name=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\ARCHIVELOG\2011_0
4_25\O1_MF_1_14_6VCJBXKV_.ARC thread=1 sequence=14
media recovery complete, elapsed time: 00:00:01
Finished recover at 25-APR-11

database opened

contents of Memory Script:
{
# make read only the tablespace that will be exported
sql clone 'alter tablespace  RMANTBS read only';
# create directory for datapump import
sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
C:\TEMP\auxxtest''";
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
C:\TEMP\auxxtest''";
}
executing Memory Script

sql statement: alter tablespace  RMANTBS read only

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''C:\TEMP\auxx
test''

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''C:\TEMP\auxx
test''

Performing export of metadata...
   EXPDP> Starting "SYS"."TSPITR_EXP_mbfF":
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
   EXPDP> Master table "SYS"."TSPITR_EXP_mbfF" successfully loaded/unloaded
   EXPDP> **********************************************************************
********
   EXPDP> Dump file set for SYS.TSPITR_EXP_mbfF is:
   EXPDP>   C:\TEMP\AUXXTEST\TSPITR_MBFF_12962.DMP
   EXPDP> **********************************************************************
********
   EXPDP> Datafiles required for transportable tablespace RMANTBS:
   EXPDP>   C:\TEMP\RMNATBS01.DBF
   EXPDP> Job "SYS"."TSPITR_EXP_mbfF" successfully completed at 21:49:42
Export completed
contents of Memory Script:
{
# shutdown clone before import
shutdown clone immediate
# drop target tablespaces before importing them back
sql 'drop tablespace  RMANTBS including contents keep datafiles';
}
executing Memory Script

database closed
database dismounted
Oracle instance shut down

sql statement: drop tablespace  RMANTBS including contents keep datafiles

Performing import of metadata...
   IMPDP> Master table "SYS"."TSPITR_IMP_mbfF" successfully loaded/unloaded
   IMPDP> Starting "SYS"."TSPITR_IMP_mbfF":
   IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
   IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
   IMPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
   IMPDP> Job "SYS"."TSPITR_IMP_mbfF" successfully completed at 21:50:03
Import completed
contents of Memory Script:
{
# make read write and offline the imported tablespaces
sql 'alter tablespace  RMANTBS read write';
sql 'alter tablespace  RMANTBS offline';
# enable autobackups after TSPITR is finished
sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
}
executing Memory Script

sql statement: alter tablespace  RMANTBS read write

sql statement: alter tablespace  RMANTBS offline

sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;

Removing automatic instance
Automatic instance removed
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\DATAFILE\O1_MF_TEMP_6VCJGXY6_.T
MP deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\ONLINELOG\O1_MF_3_6VCJGTWP_.LOG
 deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\ONLINELOG\O1_MF_2_6VCJGST5_.LOG
 deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\ONLINELOG\O1_MF_1_6VCJGKK2_.LOG
 deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\DATAFILE\O1_MF_SYSAUX_6VCJCP53_
.DBF deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\DATAFILE\O1_MF_UNDOTBS1_6VCJCP5
8_.DBF deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\DATAFILE\O1_MF_SYSTEM_6VCJCP1B_
.DBF deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\CONTROLFILE\O1_MF_6VCJBORG_.CTL
 deleted
Finished recover at 25-APR-11

RMAN>

 Step 13 : After done it, Backup tablespace

RMAN>backup tablespace rmantbs;

Step 14: tablespace online

21:54:34 SQL> alter tablespace rmantbs online;

Tablespace altered.

Step 15:  Check whether truncate table recovered or not

:44 SQL> conn rmantbs/rmantbs;
Connected.
21:54:52 SQL> select * from employee;

     EMPNO EMPNAME
---------- --------------------
         1 azar
         2 jabar
         3 kareem
         4 ajmal

Now It was recovered.

Step 16: Now I’m going to check another table whether inserted data availble after done TBPITR time

21:55:01 SQL> select * from empcity;

CITYNAME
--------------------
riyadh

Not availble, So in this case I’m going to import this table data from dumpfile , this dumpfile taken before I do TBPITR

Step 17: Import table 

C:\Users\Azar>impdp rmantbs/rmantbs directory=data_pump_dir dumpfile=datatbs.dmp
 logfile=datatbsimp.log tables=empcity table_exists_action=append

Import: Release 11.2.0.1.0 - Production on Mon Apr 25 21:58:40 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "RMANTBS"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "RMANTBS"."SYS_IMPORT_TABLE_01":  rmantbs/******** directory=data_pump_
dir dumpfile=datatbs.dmp logfile=datatbsimp.log tables=empcity table_exists_acti
on=append
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39152: Table "RMANTBS"."EMPCITY" exists. Data will be appended to existing t
able but all dependent metadata will be skipped due to table_exists_action of ap
pend
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "RMANTBS"."EMPCITY"                         5.062 KB       4 rows
Job "RMANTBS"."SYS_IMPORT_TABLE_01" completed with 1 error(s) at 21:58:42

21:55:09 SQL> conn rmantest/rmantest;
Connected.
21:55:28 SQL> select * from a;

     EMPNO
----------
         1
         2
         3
         4
         5

Step 18: And also I was checked , the other tablespace allocate table data consistent, Yes.

21:55:33 SQL> conn rmantbs/rmantbs;
Connected.
21:59:03 SQL> select * from empcity;

CITYNAME
--------------------
riyadh
riyadh
chennai
trichy
dammam

21:59:05 SQL>

Now Successfully Done It RMAN tablespace Point in time recovery.

 

 

 

 

OTN forum question about windows schedule batch

Today morning OTN user asked ,How do we do following scenario

“TASK: Create a script that would backup, truncate, and import data on the 2 schema of DEV server.
This script will be attached in the Scheduled Task in Windows.

I am task to periodically refresh a developement environment using the prod database for users testing
Every weekend, I have to export the PROD schema from the prod server and import it to the DEV schema at the dev server.

I am task to create a scheduled batch job (.bat) to do this activity at the DEV server side only. The PROD export file backup is assumed the be in place at dev server c:\prod1.dmp

1. export DEV schema (backup first)
2. kill all oracle user in dev server.
3. truncate all tables in DEV schema.
4. import the prod dump.

I have simple .bat script for #1,3,4 (e.g. exp dev_schema/dev_schema file=c:\dev_bak(date).dmp log=c:\dev_bak(date).log rows=y)

How do I make variable date in the backupfile?

Can you help me create .bat to kill oracle users? Can my truncate get error if there are users accessing the tables?

Do you have sample .bat script that check first the first program if successful, then proceed to next program? “

http://forums.oracle.com/forums/thread.jspa?threadID=2212289&tstart=0

I just worked out about the scenario and after done it I just posted here, It may get a idea for OTN user.

SQL> create table emptest(city varchar2(20));

Table created.

SQL> insert into emptest values('trichy');

1 row created.

SQL> insert into emptest values('dubai');

1 row created.

SQL> insert into emptest values('khobar');

1 row created.

SQL> insert into emptest values('dammam');

1 row created.

SQL> insert into emptest values('riyadh');

1 row created.

SQL> insert into emptest values('chennai');

1 row created.

SQL> commit;

Commit complete.

SQL>

Now I’m going to export particular table rows only

SQL> $exp tempuser/tempuser file=d:\temp\tempuser.dmp log=d:\temp\tempuser.log tables=emptest 
rows=y

Export: Release 11.2.0.2.0 - Beta on Mon Apr 25 10:58:16 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table                        EMPTEST          6 rows exported
Export terminated successfully without warnings.

SQL>

Now I’m going to write windows batch file for What OTN user asked
Open notepad and write it following scripts and Saved as D:\temp\exp.bat

C:

set oracle_sid=rmantbs

exp tempuser/tempuser file=d:\temp\tempuser01.dmp log=d:\temp\tempuser01.log direct=y consistent=y
 statistics='none'

sqlplus / as sysdba @D:\temp\killsession.sql

sqlplus tempuser/tempuser @D:\temp\truncate.sql

imp tempuser/tempuser file=d:\temp\tempuser.dmp log=d:\temp\tempuser.log tables=emptest 
rows=y ignore=y
 

Here I want explain about the above commands
C: –> I’m going to run from D:\temp path, so that I move to C: path
set oracle_sid=rmantbs — Set database name
exp — Export schema data
sqlplus / as sysdba @D:\temp\killsession.sql — Here I attached one killsession script here, this script killed who logged this particular schema,
Killsession.sql contain following

create or replace procedure kill_session( p_sid in number, p_serial# in number )
as
begin
 for x in ( select *
 from v$session 
 where username = 'TEMPUSER'
 and sid = p_sid
 and serial# = p_serial# )
 loop
 execute immediate 'alter system kill session ''' || 
 p_sid || ',' || p_serial# || '''';
 dbms_output.put_line( 'Alter session done' );
 end loop;
end;
/

exit
 
I got this script from http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:6633782199868

and then
sqlplus tempuser/tempuser @D:\temp\truncate.sql — Here I attached one truncate.sql script here, this script used to truncate particular table and exit from sql prompt
truncate.sql script contain following

truncate table emptest;

exit
 

and finally
imp — I just imported table rows into particular truncate table.


Now It’s works fine.It may get idea for you, you can develop from this one 🙂

mount ntfs file system to linux

When i tried to load my usb (NTFS),It showing “Could not open NTFS file system on Linux”.  So I just followed follow steps and then I can easily access NTFS file system on my Linux machine

Step 1: After inserted USB, Identify file system


[root@localhost ~]# fdisk -l | grep NTFS
/dev/sdh1               1        1940     1955488+   7  HPFS/NTFS

Step 2: Make one directory for mounting point

[root@localhost ~]# mkdir /mount/usb

Step 3: Download Fuse

http://easynews.dl.sourceforge.net/sourceforge/fuse/fuse-2.7.1.tar.gz

Step 4: Install Fuse


[root@localhost tmp]# tar xzf fuse-2.7.1.tar.gz
[root@localhost tmp]# ls
fuse-2.7.1         gconfd-oracle  gedit.oracle.2790729715  mapping-root  ssh-bTFQuC4798       VMwareDnD    VMwareTools-8.1.4-227600.tar.gz
fuse-2.7.1.tar.gz  gconfd-root    keyring-iqtBmT           orbit-root    virtual-root.drjpsz  vmware-root  vmware-tools-distrib
[root@localhost tmp]# cd fuse-2.7.1
[root@localhost fuse-2.7.1]# ls
aclocal.m4  compile       config.sub    COPYING      doc      Filesystems  INSTALL     lib          Makefile.in    NEWS        util
AUTHORS     config.guess  configure     COPYING.LIB  example  fuse.pc.in   install-sh  ltmain.sh    missing        README
ChangeLog   config.rpath  configure.in  depcomp      FAQ      include      kernel      Makefile.am  mkinstalldirs  README.NFS
[root@localhost fuse-2.7.1]# ./configure --exec-prefix=/;
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 32768
checking whether the shell understands some XSI constructs... yes
checking for /usr/bin/ld option to reload object files... -r
checking how to recognise dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking whether gcc and cc understand -c and -o together... yes
checking for fork... yes
checking for setxattr... yes
checking for fdatasync... yes
checking for struct stat.st_atim... yes
checking for struct stat.st_atimespec... no
checking for library containing dlopen... -ldl
checking for library containing clock_gettime... -lrt
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for shared library run path origin... done
checking for iconv... yes
checking for iconv declaration...
         extern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
configure: creating ./config.status
config.status: creating fuse.pc
config.status: creating Makefile
config.status: creating lib/Makefile
config.status: creating util/Makefile
config.status: creating example/Makefile
config.status: creating include/Makefile
config.status: creating include/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
=== configuring in kernel (/tmp/fuse-2.7.1/kernel)
configure: running /bin/sh ./configure '--prefix=/usr/local'  '--exec-prefix=/' --cache-file=/dev/null --srcdir=.
checking for a BSD-compatible install... /usr/bin/install -c
checking if FUSE is loaded as a module... no
checking if FUSE module is built into the kernel... no
checking if FUSE module is from official kernel... yes
configure:
NOTE:     Detected that FUSE is already present in the kernel, so
NOTE:     building of kernel module is disabled.  To force building
NOTE:     of kernel module use the '--enable-kernel-module' option.
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
[root@localhost fuse-2.7.1]#

[root@localhost fuse-2.7.1]# make
Making all in kernel
make[1]: Entering directory `/tmp/fuse-2.7.1/kernel'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/tmp/fuse-2.7.1/kernel'
Making all in include
make[1]: Entering directory `/tmp/fuse-2.7.1/include'
make  all-am
make[2]: Entering directory `/tmp/fuse-2.7.1/include'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/tmp/fuse-2.7.1/include'
make[1]: Leaving directory `/tmp/fuse-2.7.1/include'
Making all in lib
make[1]: Entering directory `/tmp/fuse-2.7.1/lib'
if /bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I../include  -I../include -DFUSERMOUNT_DIR=\"//bin\" -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DFUSE_USE_VERSION=26   -Wall -W -Wno-sign-compare -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings -g -O2 -fno-strict-aliasing -MT fuse.lo -MD -MP -MF ".deps/fuse.Tpo" -c -o fuse.lo fuse.c; \
[root@localhost fuse-2.7.1]# make install
Making install in kernel
make[1]: Entering directory `/tmp/fuse-2.7.1/kernel'
make[1]: Nothing to be done for `install'.
make[1]: Leaving directory `/tmp/fuse-2.7.1/kernel'
Making install in include
make[1]: Entering directory `/tmp/fuse-2.7.1/include'
make[2]: Entering directory `/tmp/fuse-2.7.1/include'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/include/fuse" || mkdir -p -- "/usr/local/include/fuse"
 /usr/bin/install -c -m 644 'fuse.h' '/usr/local/include/fuse/fuse.h'
 /usr/bin/install -c -m 644 'fuse_compat.h' '/usr/local/include/fuse/fuse_compat.h'
 /usr/bin/install -c -m 644 'fuse_common.h' '/usr/local/include/fuse/fuse_common.h'
 /usr/bin/install -c -m 644 'fuse_common_compat.h' '/usr/local/include/fuse/fuse_common_compat.h'
 /usr/bin/install -c -m 644 'fuse_lowlevel.h' '/usr/local/include/fuse/fuse_lowlevel.h'
 /usr/bin/install -c -m 644 'fuse_lowlevel_compat.h' '/usr/local/include/fuse/fuse_lowlevel_compat.h'
 /usr/bin/install -c -m 644 'fuse_opt.h' '/usr/local/include/fuse/fuse_opt.h'
test -z "/usr/local/include" || mkdir -p -- "/usr/local/include"

Step 5:  Download ntfs-3g

http://linux.softpedia.com/get/System/Hardware/ntfs-3g-15028.shtml

Step 6: Install ntfs-3g


[root@localhost tmp]# tar xzf ntfs-3g-2011.1.15.tgz
[root@localhost tmp]# ls
fuse-2.7.1         gconfd-oracle  gedit.oracle.2790729715  mapping-root       ntfs-3g-2011.1.15.tgz  ssh-bTFQuC4798       VMwareDnD    VMwareTools-8.1.4-227600.tar.gz
fuse-2.7.1.tar.gz  gconfd-root    keyring-iqtBmT           ntfs-3g-2011.1.15  orbit-root             virtual-root.drjpsz  vmware-root  vmware-tools-distrib
[root@localhost tmp]# cd ntfs-3g-2011.1.15
[root@localhost ntfs-3g-2011.1.15]# ls
aclocal.m4  autogen.sh  compile       config.h.in  configure     COPYING      CREDITS  include  install-sh    libntfs-3g  m4           Makefile.in  NEWS    src
AUTHORS     ChangeLog   config.guess  config.sub   configure.ac  COPYING.LIB  depcomp  INSTALL  libfuse-lite  ltmain.sh   Makefile.am  missing      README
[root@localhost ntfs-3g-2011.1.15]#  ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
[root@localhost ntfs-3g-2011.1.15]# make
make  all-recursive
make[1]: Entering directory `/tmp/ntfs-3g-2011.1.15'
Making all in include
make[2]: Entering directory `/tmp/ntfs-3g-2011.1.15/include'
Making all in ntfs-3g
make[3]: Entering directory `/tmp/ntfs-3g-2011.1.15/include/ntfs-3g'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/tmp/ntfs-3g-2011.1.15/include/ntfs-3g'
Making all in fuse-lite
make[3]: Entering directory `/tmp/ntfs-3g-2011.1.15/include/fuse-lite'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/tmp/ntfs-3g-2011.1.15/include/fuse-lite'
make[3]: Entering directory `/tmp/ntfs-3g-2011.1.15/include'
make[3]: Nothing to be done for `all-am'.
[root@localhost ntfs-3g-2011.1.15]# make install
Making install in include
make[1]: Entering directory `/tmp/ntfs-3g-2011.1.15/include'
Making install in ntfs-3g
make[2]: Entering directory `/tmp/ntfs-3g-2011.1.15/include/ntfs-3g'
make[3]: Entering directory `/tmp/ntfs-3g-2011.1.15/include/ntfs-3g'
make[3]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/include/ntfs-3g" || /bin/mkdir -p "/usr/local/include/ntfs-3g"
 /usr/bin/install -c -m 644 'acls.h' '/usr/local/include/ntfs-3g/acls.h'
 /usr/bin/install -c -m 644 'attrib.h' '/usr/local/include/ntfs-3g/attrib.h'
 /usr/bin/install -c -m 644 'attrlist.h' '/usr/local/include/ntfs-3g/attrlist.h'
 /usr/bin/install -c -m 644 'bitmap.h' '/usr/local/include/ntfs-3g/bitmap.h'
 /usr/bin/install -c -m 644 'bootsect.h' '/usr/local/include/ntfs-3g/bootsect.h'
 /usr/bin/install -c -m 644 'cache.h' '/usr/local/include/ntfs-3g/cache.h'
 /usr/bin/install -c -m 644 'collate.h' '/usr/local/include/ntfs-3g/collate.h'
 /usr/bin/install -c -m 644 'compat.h' '/usr/local/include/ntfs-3g/compat.h'

Step 7:  Mount ntfs

[root@localhost ~]# mount -t ntfs-3g /dev/sdh1 /mount/usb
The disk contains an unclean file system (0, 0).
The file system wasn't safely closed on Windows. Fixing.
[root@localhost ~]# cd /mount/usb
[root@localhost usb]# ls
hinew.txt  rpm11g
[root@localhost usb]# rm hinew.txt
rm: remove regular empty file `hinew.txt'? y
[root@localhost usb]# ls
rpm11g
[root@localhost usb]#

Unmount
[root@localhost ~]# umount /mount/usb
[root@localhost ~]# cd /mount/usb
[root@localhost usb]# ls
[root@localhost usb]# ls -ltr
total 0
[root@localhost usb]#