Thursday, March 29, 2012
Oracle Parallel Execution
Wednesday, March 28, 2012
Role Creation Using Network Link
User Creation using Network Link
Common Error And Solutions
1. Oracle Memory Sizing
RAM = 4GB
Databases =4
-----------For Old Year
Connect to old year database SQLPLUSW sys/oracle@apx0910srv AS SYSDBA
Create pfile from spfile;
show parameter sga
show parameter pga
alter system set sga_target=500M;
alter system set sga_max_size=500M scope=spfile;
alter system set pga_aggregate_target=100M;
shutdown immediate
startup
----------------For Current and Last Year
Connect to old year database SQLPLUSW sys/oracle@apx1213srv AS SYSDBA
SQLPLUSW sys/oracle@apx1112srv AS SYSDBA
Create pfile from spfile;
show parameter sga
show parameter pga
alter system set sga_target=800M;
alter system set sga_max_size=800M scope=spfile;
alter system set pga_aggregate_target=300M;
shutdown immediate
startup
Note1: For 32 bit server, Max Oracle Memory Limit 2*32bits (1.7GB)
Don't give more that 1.5 gb to sga otherwise oracle will not started
Note2: Please disable all OracleJobScheduler, OracleDBConsole services from services.msc
Note3: Stop Archiving for old year databases
2. Change Utl_file_dir location
create pfile from spfile;
Alter system set utl_file_dir='D:\ldoutput' Scope=spfile ;
shut immediate
startup
3. How to set default tablespace as USR ?
select * from database_properties where property_name like '%TABLESPACE';
Alter Database default tablespace "USR" ;
4. At the time of LD Login it shows error message "Oracle Not Available" or Shared Memory Realm does not exist ?
Manually start database
sqlplusw sys@apx1213srv as sysdba
startup
5.for ld digital
sqlplusw sys@apx1213srv as sysdba
CREATE DIRECTORY LDDGITAL AS 'd:\ldoutput\Lddigital';
grant read, write on directory LDDIGITAL to ldbo;
6. If any entry of LISTENER_APX1213 in tnsnames.ora then remove it.
show parameter listener
create pfile from spfile;
alter system set local_listener='' scope=spfile;
shut immediate
start
7. if listener shows error
run listener services from windows command prompt to view right status
lsnrctl status
lsnrctl stop
lsnrctl start
8. Master Transmission Performance
1) delete from CLIENTSCANNEDIMAGE; before master transmission for better performance
2) create table from sql
3) later imp clientscannedimage table
exp ldbo@ldbo@apx1112srv file='d:\expdp1112\tblclientscan.dmp' log='d:\expdp1112\tblclientscan.log' TABLES= CLIENTSCANNEDIMAGE
imp ldbo@ldbo@apx1213srv file='d:\expdp1112\tblclientscan.dmp' log='d:\expdp1112\tblclientscan1.log'
9. if Space Issue, Stop Archiving at time of import or other long insert / update / transmission process. Later enable
Disable Archiving
sqlplusw sys@apx1213srv as sysdba
shut immediate
startup mount
alter database noarchivelog;
alter database open;
Enable Archiving
shut immediate
startup mount
alter database archivelog;
alter database open;
10. unable to extend <> segment by <> in tablespace USR
ALTER TABLESPACE USR
ADD DATAFILE 'D:\APXD1213\USERS2.ORA' SIZE 2048M
AUTOEXTEND ON
NEXT 1024M
MAXSIZE unlimited;
11. ora-01536 space quota exceed
ALTER USER LDBO QUOTA UNLIMITED on USR;
ALTER USER LDBO QUOTA UNLIMITED on INDX;
12. ORA-38029 object statistics are locked
select 'exec DBMS_STATS.UNLOCK_TABLE_STATS('''||owner||''','''||table_name||''');' from dba_tab_statistics where stattype_locked is not null and owner not in ('SYS','SYSTEM');
RUN THE OUTPUT RESULT
13. ORA-25153 Temporary Tablespace is Empty
ALTER TABLESPACE temporary ADD tempfile 'D:\APX1213D\TEMP01.ORA' SIZE 1000M REUSE AUTOEXTEND ON NEXT 500M MAXSIZE unlimited;
14. ORA-20014: %s Brokerage cannot be Run. ~-27477~ORA-27477: "LDBO.C_BSENM1112177_J" already exists
BEGIN
DBMS_SCHEDULER.DROP_JOB (
job_name => 'C_BSENM1112177_J');
END;
/
15. Tablespace, Datafiles Details
select tablespace_name,block_size,INITIAL_EXTENT/1024,MAX_EXTENTS/1024/1024/1024,segment_space_management,bigfile from dba_tablespaces;
select file_name,tablespace_name,bytes/1024/1024,autoextensible,increment_by from dba_temp_files;
select file_name,tablespace_name,bytes/1024/1024,MAXbytes/1024/1024,autoextensible,increment_by from dba_data_files;
16. Partitioned Table Details
select table_name from user_part_tables;
select name,column_name from user_part_key_columns;
select * from user_tab_partitions;
17.
If following ODBC error (Mostly occur at Large DB / Partitioned Table Clients)
Most Critical Error In Oracle ORA-00600
[Microsoft][ODBC driver for Oracle][Oracle]ORA-00600: internal error code, arguments: [15735], [2168], [2152], [], [], [], [], []
solution:
sqlplusw sys@apx1213srv as sysdba
create pfile from spfile;
show parameter parallel_automatic_tuning
alter system set parallel_automatic_tuning=TRUE scope=spfile;
alter system set parallel_execution_message_size=4096 scope=spfile;
shut immediate
startup
18. Enable / Disable Trigger
Alter Trigger
Alter Trigger
19. Enable / Disable Constraint
Alter Table
Alter Table
20. ORA-14402 updating partition key column would cause a partition change
ALTER TABLE
21. COMPILE OBJECT ERROR
ORA-02019: connection description for remote database not found
TABLE VIEW DOES NOT EXIST
ADD DATABASE LINK
CREATE PUBLIC DATABASE LINK "LNK_RAKSHAK"
CONNECT TO "LDBO" IDENTIFIED BY password USING 'apx1213srv';
CREATE PUBLIC DATABASE LINK "LNK_CCM"
CONNECT TO "LDBO" IDENTIFIED BY password USING 'apx1213srv';
CREATE DATABASE LINK "LNK_DIGITAL"
CONNECT TO "LDBO" IDENTIFIED BY password USING 'apx1213srv';
Saturday, March 24, 2012
PGA Top Consumer
PGA incease When???
Oracle Hidden Parameter
Oracle 10g Scheduler Job Email Notification
SQL> conn sys@apx1213 as sysdba
Enter password: ******
Connected.
SQL> @d:\oracle\product\10.2.0\db_1\rdbms\admin\utlmail.sql
Package created.
Synonym created.
SQL> @d:\oracle\product\10.2.0\db_1\rdbms\admin\prvtmail.plb;
Package body created.
No errors.
2) Set SMTP_OUT_SERVER parameter for smtp_exchange_server. This parameter is not modifiable means we have to bounce our database to set this parameter
SQL> alter system set smtp_out_server = 'mail.apexsoftcell.com' scope=spfile;
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
3) Grant EXECUTE privs to user which use utl_mail package.
SQL> grant execute on utl_mail to ldbo;
Grant succeeded.
) Create procedure for Email Notification
create or replace procedure PRC_EMAIL (pSubject IN VARCHAR2, pMessage IN VARCHAR2) is
BEGIN
utl_mail.send(sender => 'info@apexsoftcell.com', recipients => 'kshitij@apexsoftcell.com', subject => pSubject, message => pMessage);
END;
/
4) Create Scheduler Job
BEGIN
DBMS_SCHEDULER.drop_JOB (job_name => 'compile');
END;
/
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'compile',
job_type => 'PLSQL_BLOCK',
job_action => 'DECLARE lnResult VARCHAR2(150);
BEGIN UTL_RECOMP.recomp_serial(''LDBO''); lnResult:=''SUCCESS'';
PRC_EMAIL(''Compile Notification'',lnResult);
EXCEPTION WHEN OTHERS THEN lnResult:=SUBSTR(SQLERRM,1,150);
PRC_EMAIL(''Compile Notification'',lnResult);
END;',
start_date => SYSTIMESTAMP,
repeat_interval => 'freq=hourly; byminute=0; bysecond=0;',
end_date => NULL,
enabled => TRUE,
comments => 'Compile job');
END;
/
5) Execute Job Manually
exec DBMS_SCHEDULER.run_job ('compile');
Thursday, March 15, 2012
Server Configuration Planning
Hardware Requirement
Database Growth Monitoring
select sum(bytes)/1024/1024 "TOTAL SIZE (MB)" from dba_Data_files;
Step : 2 Calculate Free Space in Tablespace
select sum(bytes)/1024/1024 "FREE SPACE (MB)" from dba_free_space;
Step : 3 Calculate total size , free space and used space in tablespace
select t2.total "TOTAL DISK USAGE",t1.free "FREE SPACE",(t1.free/t2.total)*100 "FREE (%)",(t2.total-t1.free) "USED SPACE", (1-t1.free/t2.total)*100 "USED (%)"
from (select sum(bytes)/1024/1024 free from dba_free_space) t1 , (select sum(bytes)/1024/1024 total from dba_Data_files) t2 ;
Step : 4 Create table which is store all free/use space related information of tablespace
create table db_growth
as select *
from (
select sysdate,t2.total "TOTAL_DISK_USAGE",t1.free "FREE_SPACE",(t2.total-t1.free) "USED_SPACE",(t1.free/t2.total)*100 "FREE% "
from
(select sum(bytes)/1024/1024 free
from dba_free_space) t1 ,
(select sum(bytes)/1024/1024 total
from dba_Data_files) t2
);
Step : 5 Insert free space information in DB_GROWTH table (if you want to populate data Manually)
insert into db_growth
select *
from (
select sysdate,t2.total "TOTAL_SIZE",t1.free "FREE_SPACE",(t2.total-t1.free) "USED_SPACE",(t1.free/t2.total)*100 "FREE%"
from
(select sum(bytes)/1024/1024 free
from dba_free_space) t1 ,
(select sum(bytes)/1024/1024 total
from dba_Data_files) t2
);
COMMIT;
Step : 6 Create View on DB_GROWTH based table ( This Steps is Required if you want to populate data automatically)
create view v_db_growth
as select *
from
(
select sysdate,t2.total "TOTAL_SIZE",t1.free "FREE_SPACE",(t2.total-t1.free) "USED_SPACE",(t1.free/t2.total)*100 "FREE%"
from
(select sum(bytes)/1024/1024 free
from dba_free_space) t1 ,
(select sum(bytes)/1024/1024 total
from dba_Data_files) t2
)
;
Step : 7 Insert data into DB_GROWTH table from V_DD_GROWTH view
insert into db_growth select *
from v_db_growth;
COMMIT;
Step : 8 Check everything goes fine.
select * from db_growth;
Check Result
Step : 9 Execute following SQL for more time stamp information
alter session set nls_date_format ='dd-mon-yyyy hh24:mi:ss' ;
Session altered.
Step : 10 Create a DBMS jobs which execute after 24 hours
declare
jobno number;
begin
dbms_job.submit(
jobno, 'begin insert into db_growth select * from v_db_growth;commit;end;', sysdate, 'SYSDATE+ 1', TRUE);
commit;
end;
/
PL/SQL procedure successfully completed.
Step: 11 View your dbms jobs and it's other information
select * from user_jobs;
-----If you want to execute dbms jobs manually execute following command other wise jobs is executing automatically
exec dbms_job.run(ENTER_JOB_NUMBER)
exec dbms_job.run(23);
PL/SQL procedure successfully completed.
exec dbms_job.remove(21); ------to remove a job
Step: 12 Finally all data populated in db_growth table
select * from db_growth;