Wednesday 12 September 2012

How to login to sqlplus with username which has special characters in password??

Hi friends,

Today I will show you small demostration of how to connect to the database with username which has special character in their password.



When your password has special character like "@" which we use for connect discriptor then see the following solution.

C:\Users\oradb>sqlplus hr/"hr@"@orcl
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Sep 12 18:02:38 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied

Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied

SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus

C:\Users\oradb>sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Sep 12 18:02:53 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
SQL> conn hr/"hr@"@orcl
Connected.
SQL>








Friday 7 September 2012

How to recover dropped table in 10g onwords?

Today, will look into how to recover deleted table?
10G Onwords Oracle introudces new feature of recycbin. ( Same concept as windows recyclebin)
Suppose from XYZ schema accidentely you dropped the table which is one of the important table in your database.
the table and its data still availble in "bin".
What Oracle does when you delete the table?
Oracle Simply rename table with differnt tablename start with "BINsomevalue".
Make sure you enable this recyclebin
SQL> show parameter recyclebin;
NAME                                 TYPE        VALUE
------------------------------------ ----------- --------
recyclebin                           string      on

Simply login to the scheama & fire command "show recyclebin;"


Here is demo for you.
-
SQL> conn scott
Enter password:
Connected.
SQL> desc emp1;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 EMPNO                                              NUMBER(4)
 ENAME                                              VARCHAR2(10)
 JOB                                                VARCHAR2(9)
 MGR                                                NUMBER(4)
 HIREDATE                                           DATE
 SAL                                                NUMBER(7,2)
 COMM                                               NUMBER(7,2)
 DEPTNO                                             NUMBER(2)

SQL> drop table emp1;
Table dropped.

SQL> desc emp1;
ERROR:
ORA-04043: object emp1 does not exist

SQL> show recyclebin;
ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME
---------------- ------------------------------ ------------ -------------------
EMP1             BIN$nChBttgnS/6uj2vZgTB9Ow==$0 TABLE        2012-09-07:17:58:13

SQL> flashback table emp1 to before drop;
Flashback complete.


SQL> desc emp1;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 EMPNO                                              NUMBER(4)
 ENAME                                              VARCHAR2(10)
 JOB                                                VARCHAR2(9)
 MGR                                                NUMBER(4)
 HIREDATE                                           DATE
 SAL                                                NUMBER(7,2)
 COMM                                               NUMBER(7,2)
 DEPTNO                                             NUMBER(2)



This way you recovered your dropped table.

Saturday 1 September 2012

How to Empty undo tablespace & reclaim space?

Hi,
Over the period of time Undo tablespace size (OS level) grow but actual size of it is small
then How to Empty undo tablespace & reclaim space?
empty undo tablespace
--follow steps if undo tablespace growing

--Create New UNDO tablespace UNDOTBS2

create undo tablespace UNDOTBS2 datafile 'D:\app\Administrator\oradata\DMS\undotbs101.dbf' size 1024M;

--Set default undo_tablespace to new undo tbs

alter system set undo_tablespace='UNDOTBS2' scope=both;

--Drop UNDOTBS1

drop  tablespace UNDOTBS1 including contents and datafiles;

--Create UNDO tbs UNDOTBS1

create undo tablespace UNDOTBS1 datafile 'D:\app\Administrator\oradata\DMS\undotb101.dbf' size 1024M;

--Set default undo_tablespace to UNDOTBS1

alter system set undo_tablespace='UNDOTBS1' scope=both;

--Drop UNDOTBS2

drop  tablespace UNDOTBS2 including contents and datafiles;

How to Empty Temp tablespace?

Hi,
Over the period of time if temp tablespace size (OS level) grow but actual size of it is small.
then How to Empty temp tablespace?

--Create another temporary tablespace temp2

SQL> CREATE TEMPORARY TABLESPACE temp2 TEMPFILE '/shreyas/temp02.dbf' SIZE 100M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 10M;

--Make temp2 as default temp tbs

alter database default temporary tablespace temp2;

--Drop temp tablespace

 drop tablespace temp including contents and datafiles;

--Create temp tablespace

SQL> CREATE TEMPORARY TABLESPACE temp TEMPFILE '/shreyas/temp01.dbf' SIZE 100M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 10M;

--Make temp as default temp tbs

alter database default temporary tablespace temp;

--Drop temp2 tablespace

drop tablespace temp2 including contents and datafiles;