1.Shutdown database
2.Backup the database
3. startup
4. run csscan -
C:\Documents and Settings\lingappk>csscan system/oracle full=y tochar=AL32UTF8 array=1024000 process=10
Character Set Scanner v2.0 : Release 10.1.0.4.0 - Production on Wed Nov 11 03:10:14 2009
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options
CSS-00107: Character set migration utility schema not installed
Scanner terminated unsuccessfully.
Error occured due to csmig schema is not present in the datbase. Create csmig by running default script available in oracle home folder
5.
SQL > @%oracle_home%\rdbms\admin\csminst.sql
(This script will drop csmig schema if exist and recreate will all the required privileges)
6.
csscan ”/sys as sysdba\” LOG=charconv.log FULL=Y CAPTURE=Y TOCHAR=AL32UTF8 ARRAY=1024000 PROCESS=10
OR
csscan "/sys as sysdb \" FULL=Y
(provide values when prompted)
. process 2 scanning SYS.TYPED_VIEW$[AAAAA/AABAAAAHRAAA]
. process 7 scanning SYS.UGROUP$[AAAAA5AABAAAAGpAAA]
. process 1 scanning SYS.USER$[AAAAAKAABAAAABZAAA]
. process 6 scanning SYS.FILE$[AAAAARAABAAAABxAAA]
Creating Database Scan Summary Report...
Creating Individual Exception Report...
Scanner terminated successfully.
7.
Run following script for the convertion
SQL> shutdown immediate
SQL> startup restrict
SQL> @%oracle_home%\rdbms\admin\csalter.plb
OR
SQL> shutdown immediate
SQL> startup mount
SQL> alter system enable restricted session;
SQL> alter system set JOB_QUEUE_PROCESSES=0 scope=memory;
SQL> alter system set AQ_TM_PROCESS=0 scope=memory;
SQL> alter database open;
SQL> alter database character set AL32UTF8;
alter database character set AL32UTF8*ERROR at line 1:
ORA-12712: new character set must be a superset of old character set
if u want to change the characterset then the new characterset should be a superset of the older one otherwise create a new database with different characterset
SQL> SELECT * FROM nls_database_parameters WHERE parameter like '%CHARACTERSET';
PARAMETER VALUE
NLS_CHARACTERSET WE8MSWIN1252
NLS_NCHAR_CHARACTERSET AL16UTF16
Tuesday, November 10, 2009
Wednesday, October 28, 2009
Metadata of Table/Index
1. Using the import/export is one method of getting the metadata where while exporting row=n will be defined and while importing show=y should be provide but we need to lot of editing to get formated metadata but most easiest and quick one is using DMBS_METADATA
Export/Import
c:\>exp file=motoexp.dmp log=motoexp.log rows=n buffer=1000000
c:\>imp file=motoexp.dmp log=motoim.log show=y rows=n indexfile=moto.sql buffer=1000000
DBMS_METADATA
SELECT DBMS_METADATA.get_ddl('object_type','object_name','owner') from dual;
SQL> set serveroutput on
SQL> set long 10000
SQL> set pages 0
SQL> select DBMS_METADATA.get_ddl ('TABLE','JOBS','HR') from dual;
CREATE TABLE "HR"."JOBS" ( "JOB_ID" VARCHAR2(10),
"JOB_TITLE" VARCHAR2(35) CONSTRAINT "JOB_TITLE_NN" NOT NULL ENABLE, "MIN_SALARY" NUMBER(6,0),
"MAX_SALARY" NUMBER(6,0),
CONSTRAINT "JOB_ID_PK" PRIMARY KEY ("JOB_ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "EXAMPLE" ENABLE )
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "EXAMPLE"
Find all indexes on a particular table using DBMS_METADATA
SQL> select DBMS_METADATA.get_dependent_ddl('INDEX','JOBS','HR') from dual;
CREATE UNIQUE INDEX "HR"."JOB_ID_PK" ON "HR"."JOBS" ("JOB_ID") PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "EXAMPLE"
Find all referencial constraint on a table
SQL> select DBMS_METADATA.get_dependent_dd ('REF_CONSTRAINT','EMPLOYEES','HR') from dual;
ALTER TABLE "HR"."EMPLOYEES" ADD CONSTRAINT "EMP_DEPT_FK" FOREIGN KEY ("DEPARTMENT_ID") REFERENCES "HR"."DEPARTMENTS" ("DEPARTMENT_ID") ENABLE
ALTER TABLE "HR"."EMPLOYEES" ADD CONSTRAINT "EMP_JOB_FK" FOREIGN KEY ("JOB_ID") REFERENCES "HR"."JOBS" ("JOB_ID") ENABLE
ALTER TABLE "HR"."EMPLOYEES" ADD CONSTRAINT "EMP_MANAGER_FK" FOREIGN KEY ("MANAGER_ID") REFERENCES "HR"."EMPLOYEES" ("EMPLOYEE_ID") ENABLE
Find granted privileges for a particual schema using DBMS_METADATA
SQL> select DBMS_METADATA.get_granted_ddl('SYSTEM_GRANT','HR') from dual;
GRANT UNLIMITED TABLESPACE TO "HR"
SQL> select DBMS_METADATA.get_granted_ddl('ROLE_GRANT','HR') from dual;
GRANT "CONNECT" TO "HR"
GRANT "RESOURCE" TO "HR"
SQL> select DBMS_METADATA.get_granted_ddl('OBJECT_GRANT','HR') from dual;
GRANT EXECUTE ON "SYS"."DBMS_STATS" TO "HR"
Export/Import
c:\>exp file=motoexp.dmp log=motoexp.log rows=n buffer=1000000
c:\>imp file=motoexp.dmp log=motoim.log show=y rows=n indexfile=moto.sql buffer=1000000
DBMS_METADATA
SELECT DBMS_METADATA.get_ddl('object_type','object_name','owner') from dual;
SQL> set serveroutput on
SQL> set long 10000
SQL> set pages 0
SQL> select DBMS_METADATA.get_ddl ('TABLE','JOBS','HR') from dual;
CREATE TABLE "HR"."JOBS" ( "JOB_ID" VARCHAR2(10),
"JOB_TITLE" VARCHAR2(35) CONSTRAINT "JOB_TITLE_NN" NOT NULL ENABLE, "MIN_SALARY" NUMBER(6,0),
"MAX_SALARY" NUMBER(6,0),
CONSTRAINT "JOB_ID_PK" PRIMARY KEY ("JOB_ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "EXAMPLE" ENABLE )
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "EXAMPLE"
Find all indexes on a particular table using DBMS_METADATA
SQL> select DBMS_METADATA.get_dependent_ddl('INDEX','JOBS','HR') from dual;
CREATE UNIQUE INDEX "HR"."JOB_ID_PK" ON "HR"."JOBS" ("JOB_ID") PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "EXAMPLE"
Find all referencial constraint on a table
SQL> select DBMS_METADATA.get_dependent_dd ('REF_CONSTRAINT','EMPLOYEES','HR') from dual;
ALTER TABLE "HR"."EMPLOYEES" ADD CONSTRAINT "EMP_DEPT_FK" FOREIGN KEY ("DEPARTMENT_ID") REFERENCES "HR"."DEPARTMENTS" ("DEPARTMENT_ID") ENABLE
ALTER TABLE "HR"."EMPLOYEES" ADD CONSTRAINT "EMP_JOB_FK" FOREIGN KEY ("JOB_ID") REFERENCES "HR"."JOBS" ("JOB_ID") ENABLE
ALTER TABLE "HR"."EMPLOYEES" ADD CONSTRAINT "EMP_MANAGER_FK" FOREIGN KEY ("MANAGER_ID") REFERENCES "HR"."EMPLOYEES" ("EMPLOYEE_ID") ENABLE
Find granted privileges for a particual schema using DBMS_METADATA
SQL> select DBMS_METADATA.get_granted_ddl('SYSTEM_GRANT','HR') from dual;
GRANT UNLIMITED TABLESPACE TO "HR"
SQL> select DBMS_METADATA.get_granted_ddl('ROLE_GRANT','HR') from dual;
GRANT "CONNECT" TO "HR"
GRANT "RESOURCE" TO "HR"
SQL> select DBMS_METADATA.get_granted_ddl('OBJECT_GRANT','HR') from dual;
GRANT EXECUTE ON "SYS"."DBMS_STATS" TO "HR"
Wednesday, October 21, 2009
ORA-00604: error occurred at recursive SQL level 1
check out if the next error on the stack can be corrected
ORA-00020: maximum number of processes (%s) exceeded
User & Application users were unable to connect to database due to error ORA-00020 max number of processes. No new connection could be establised.
check for following
1. Process parameter setting in init file :
$ORACLE_HOME/dbs/initfile
processes = 200
2. Number of database connections
ps -aef grep oracle grep LOCAL grep wc -l
192
3. Number of database connections
ps -ef grepwc -l
203
Workaround 1:
kill some of the connections
Unix
kill -9
window
orakill
4. shutdown immediate / shutdown abort / startup force
Note 1:
When instance is out of processes, non-SYSDBA will get error with ORA-0020, and a SYSDBA connection will error out with "Connected to idle instance."
Note 2:
if there is no prior connection before ORA-00020 error one migh face problem in shutting down the instance.
SQL> shutdown immediate
ORA-24324: service handle not initialized
ORA-24323: value not allowed
ORA-00020: maximum number of processes (%s) exceeded
SQL> exit
Workaround 2:
1.Kill couple of old connections at OS level
2.Connect to database and determine which user is consuming more connections and kill the same.
Query
select s.osuser,p.spid,s.username,s.sid,s.serial#,to_char(s.logon_time,'Dy dd Mon HH24:MI:SS') start_time,s.status,s.machine,s.MODULEfrom V$PROCESS p,V$SESSION s where s.paddr = p.addr and s.username is not null;
3. alter system kill session 'SID, SERAL#';
Increasing the Process Parameter 1:
show parameter processes;
create pfile from spfile;
shut immediate;
startup mount;
alter system set processes=500 scope=spfile;
create pfile from spfile;
alter database open;
shutdown immediate;
startup;
show parameter processes;
Increasing the Process Parameter 2:
alter system set processes=500 scope=spfile;
shutdown immediate;
startup;
check for following
1. Process parameter setting in init file :
$ORACLE_HOME/dbs/initfile
processes = 200
2. Number of database connections
ps -aef grep oracle grep
192
3. Number of database connections
ps -ef grep
203
Workaround 1:
kill some of the connections
Unix
kill -9
window
orakill
4. shutdown immediate / shutdown abort / startup force
Note 1:
When instance is out of processes, non-SYSDBA will get error with ORA-0020, and a SYSDBA connection will error out with "Connected to idle instance."
Note 2:
if there is no prior connection before ORA-00020 error one migh face problem in shutting down the instance.
SQL> shutdown immediate
ORA-24324: service handle not initialized
ORA-24323: value not allowed
ORA-00020: maximum number of processes (%s) exceeded
SQL> exit
Workaround 2:
1.Kill couple of old connections at OS level
2.Connect to database and determine which user is consuming more connections and kill the same.
Query
select s.osuser,p.spid,s.username,s.sid,s.serial#,to_char(s.logon_time,'Dy dd Mon HH24:MI:SS') start_time,s.status,s.machine,s.MODULEfrom V$PROCESS p,V$SESSION s where s.paddr = p.addr and s.username is not null;
3. alter system kill session 'SID, SERAL#';
Increasing the Process Parameter 1:
show parameter processes;
create pfile from spfile;
shut immediate;
startup mount;
alter system set processes=500 scope=spfile;
create pfile from spfile;
alter database open;
shutdown immediate;
startup;
show parameter processes;
Increasing the Process Parameter 2:
alter system set processes=500 scope=spfile;
shutdown immediate;
startup;
Sunday, October 18, 2009
ORA-27037: unable to obtain file status
- It could be a missing archivelog file
- It could be a file mentioned in your init.ora file .
In case 1 :
Try to switch log file and resolve the issue. If rman is missing crosscheck the archvielog and backup once again.
- It could be a file mentioned in your init.ora file .
In case 1 :
Try to switch log file and resolve the issue. If rman is missing crosscheck the archvielog and backup once again.
Free Space available in TEMP Segment
Error : ORA-1652: unable to extend temp segment by 128 in tablespace TEMP
In database there may be permanent and temporary tablespace. The view DBA_FREE_SPACE allows us to show about how much free space in a tablespace have but DBA_FREE_SPACE shows information only about permanent tablespace. It does not show information about temporary tablespace.
v$temp_space_header and v$sort_segment are not supposed to reconcile with each other. The blocks in temp_space_header are the total number of "initialized" blocks in the tempfiles. The blocks in sort_segment are the total number of allocated and usable blocks. Which is evident in following example.
V$TEMP_SPACE_HEADER
ODSPROD1> SELECT TABLESPACE_NAME, FILE_ID, BYTES_USED, BYTES_FREE FROM V$TEMP_SPACE_HEADER;
TABLESPACE_NAME FILE_ID BYTES_USED BYTES_FREE
---------------------------------------- ---------- ---------- ----------
TEMP 3 3145719808 0
TEMP 4 3145719808 0
TEMP 5 3145719808 0
TEMP 6 1073741824 0
TEMP 7 838860800 0
TEMP 1 3145719808 0
TEMP 2 3145719808 0
7 rows selected.
V$SORT_SEGMENT
SELECT tablespace_name,
total_blocks,
used_blocks,
free_blocks,
total_blocks*16/1024 as total_MB,
used_blocks*16/1024 as used_MB,
free_blocks*16/1024 as free_MB
FROM v$sort_segment;
TABLESPACE_NAME TOTAL_BLOCKS USED_BLOCKS FREE_BLOCKS TOTAL_MB USED_MB FREE_MB
---------------------------------------- ------------ ----------- ----------- -------
TEMP 2152576 0 2152576 33634 0 33634
SEGMENT USED:
SELECT b.TABLESPACE,
b.segfile#,
b.segblk#,
b.blocks,
b.blocks*16/1024 as MB,
a.SID,
a.serial#,
a.status
FROM v$session a,
v$sort_usage b
WHERE a.saddr = b.session_addr
ORDER BY b.TABLESPACE,
b.segfile#,
b.segblk#,
b.blocks;
Oracle 9i does not release allocated TEMP segments until you shutdown the database. While the TEMP segment is allocated, it does not mean that it is unavailable for use. When a user requests a disk sort, Oracle will allocate a TEMP segment. Once that sort is done, Oracle releases this TEMP segment for future use, but does not deallocate it. When the next user requests a disk sort, Oracle does not have to allocate a new TEMP segment. It uses the same one that no user is currently using. Oracle manages this for you in 9i. And there is really only one TEMP segment in the TEMP tablespace. Multiple users can utilitize this one segment.
There have been problems in 9i where users running a TEMPORARY TEMP tablespace with TEMPFILES that is Locally Managed where Oracle does not release the sort space once it is no longer being used. This is a known bug. The workaround has been to revert back to Dictionary Managed tablespace for TEMP.
In database there may be permanent and temporary tablespace. The view DBA_FREE_SPACE allows us to show about how much free space in a tablespace have but DBA_FREE_SPACE shows information only about permanent tablespace. It does not show information about temporary tablespace.
v$temp_space_header and v$sort_segment are not supposed to reconcile with each other. The blocks in temp_space_header are the total number of "initialized" blocks in the tempfiles. The blocks in sort_segment are the total number of allocated and usable blocks. Which is evident in following example.
V$TEMP_SPACE_HEADER
ODSPROD1> SELECT TABLESPACE_NAME, FILE_ID, BYTES_USED, BYTES_FREE FROM V$TEMP_SPACE_HEADER;
TABLESPACE_NAME FILE_ID BYTES_USED BYTES_FREE
---------------------------------------- ---------- ---------- ----------
TEMP 3 3145719808 0
TEMP 4 3145719808 0
TEMP 5 3145719808 0
TEMP 6 1073741824 0
TEMP 7 838860800 0
TEMP 1 3145719808 0
TEMP 2 3145719808 0
7 rows selected.
V$SORT_SEGMENT
SELECT tablespace_name,
total_blocks,
used_blocks,
free_blocks,
total_blocks*16/1024 as total_MB,
used_blocks*16/1024 as used_MB,
free_blocks*16/1024 as free_MB
FROM v$sort_segment;
TABLESPACE_NAME TOTAL_BLOCKS USED_BLOCKS FREE_BLOCKS TOTAL_MB USED_MB FREE_MB
---------------------------------------- ------------ ----------- ----------- -------
TEMP 2152576 0 2152576 33634 0 33634
SEGMENT USED:
SELECT b.TABLESPACE,
b.segfile#,
b.segblk#,
b.blocks,
b.blocks*16/1024 as MB,
a.SID,
a.serial#,
a.status
FROM v$session a,
v$sort_usage b
WHERE a.saddr = b.session_addr
ORDER BY b.TABLESPACE,
b.segfile#,
b.segblk#,
b.blocks;
Oracle 9i does not release allocated TEMP segments until you shutdown the database. While the TEMP segment is allocated, it does not mean that it is unavailable for use. When a user requests a disk sort, Oracle will allocate a TEMP segment. Once that sort is done, Oracle releases this TEMP segment for future use, but does not deallocate it. When the next user requests a disk sort, Oracle does not have to allocate a new TEMP segment. It uses the same one that no user is currently using. Oracle manages this for you in 9i. And there is really only one TEMP segment in the TEMP tablespace. Multiple users can utilitize this one segment.
There have been problems in 9i where users running a TEMPORARY TEMP tablespace with TEMPFILES that is Locally Managed where Oracle does not release the sort space once it is no longer being used. This is a known bug. The workaround has been to revert back to Dictionary Managed tablespace for TEMP.
Profile
How to execute .profile without logging in
. ~/.profile
ways to switch over to oracle
/usr/local/bin/sudo su - oracle
/usr/local/bin/ss -u oracle
Some time after sudo home will not be set
$ id
uid=1001(oracle) gid=5006(dba)
$ pwd
/home/ffxfzq
in that case just do like this & later run the profile script
cd ~oracle
. ./.profile
. ~/.profile
ways to switch over to oracle
/usr/local/bin/sudo su - oracle
/usr/local/bin/ss -u oracle
Some time after sudo home will not be set
$ id
uid=1001(oracle) gid=5006(dba)
$ pwd
/home/ffxfzq
in that case just do like this & later run the profile script
cd ~oracle
. ./.profile
Subscribe to:
Posts (Atom)