SET serveroutput on
SET feedback off
UNDEF v_sql
DECLARE
v_task_name VARCHAR2 (100);
v_mview_owner VARCHAR2 (30) := UPPER ('&&ENTER_MVIEW_OWNER');
v_mview_name VARCHAR2 (30) := UPPER ('&&ENTER_MVIEW_NAME');
v_mview_sql VARCHAR2 (4000);
v_mview_log_sql VARCHAR2 (4000);
BEGIN
-- get mview text from data dictionary
SELECT DBMS_METADATA.get_ddl ('MATERIALIZED_VIEW', mview_name, owner)
INTO v_mview_sql
FROM dba_mviews
WHERE owner = v_mview_owner AND mview_name = v_mview_name;
SELECT DBMS_METADATA.get_dependent_ddl ('MATERIALIZED_VIEW_LOG',
referenced_name,
referenced_owner
)
INTO v_mview_log_sql
FROM dba_dependencies
WHERE referenced_type = 'TABLE'
AND referenced_name != v_mview_name
AND owner = v_mview_owner
AND NAME = v_mview_name;
DBMS_OUTPUT.put_line ('MVIEW SQL Is: ' || v_mview_sql);
DBMS_OUTPUT.put_line ('MVIEW LOG SQL Is: ' || v_mview_log_sql);
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;
/
OER 7451 in Load Indicator
Mon Aug 06 03:57:54 2012
OER 7451 in Load Indicator : Error Code = OSD-04500: illegal option specified
O/S-Error: (OS 1) Incorrect function. !
OER 7451 in Load Indicator : Error Code = OSD-04500: illegal option specified
O/S-Error: (OS 1) Incorrect function. !
Mon Aug 06 03:58:04 2012
OER 7451 in Load Indicator : Error Code = OSD-04500: illegal option specified
O/S-Error: (OS 1) Incorrect function. !
OER 7451 in Load Indicator : Error Code = OSD-04500: illegal option specified
O/S-Error: (OS 1) Incorrect function. !
Mon Aug 06 03:58:14 2012
OER 7451 in Load Indicator : Error Code = OSD-04500: illegal option specified
O/S-Error: (OS 1) Incorrect function. !
OER 7451 in Load Indicator : Error Code = OSD-04500: illegal option specified
O/S-Error: (OS 1) Incorrect function. !
Mon Aug 06 03:58:24 2012
OER 7451 in Load Indicator : Error Code = OSD-04500: illegal option specified
O/S-Error: (OS 1) Incorrect function. !
OER 7451 in Load Indicator : Error Code = OSD-04500: illegal option specified
O/S-Error: (OS 1) Incorrect function. !
Mon Aug 06 03:58:34 2012
OER 7451 in Load Indicator : Error Code = OSD-04500: illegal option specified
O/S-Error: (OS 1) Incorrect function. !
OER 7451 in Load Indicator : Error Code = OSD-04500: illegal option specified
O/S-Error: (OS 1) Incorrect function. !
Mon Aug 06 03:58:44 2012
OER 7451 in Load Indicator : Error Code = OSD-04500: illegal option specified
O/S-Error: (OS 1) Incorrect function. !
OER 7451 in Load Indicator : Error Code = OSD-04500: illegal option specified
O/S-Error: (OS 1) Incorrect function. !
Mon Aug 06 03:59:05 2012
O/S-Error: (OS 1) Incorrect function. !
Oracle Support points to Doc. ID 1060806.1
Installed 32-bit Oracle database software on a 64-bit MS Windows OS which is not supported.Note: For the Database software, you can ONLY install the x64 version on MS Windows (x64). You can NOT install the 32-bit version Database software on MS Windows (x64).
Install 32-bit Oracle database software only on 32-bit MS Windows OS.
Article / Data Guard
What Is Data Guard
Oracle Data Guard delivers high availability, data protection, and disaster recovery for the enterprise data.
Data Guard configuration consists of one production database, having primary role, and one or more standby databases, having standby roles.
Standby database can take over the production service either for planned or unplanned outages.
Apart from that it can be used for offloading the reporting and backup operations from production.
The databases in a Data Guard configuration are connected by Oracle Net and might be arranged geographically.
There are no strict network requirements for the databases to be in the same subnet and etc. It could be LAN, WAN or internet connection.
Data Guard configuration and control could be managed via:
- SQL command line interface;
- Data Guard Broker interface: using DGMRL for command line interface and GUI delivered via Oracle Enterprise Manager. Data Guard broker tool is included in Enterprise edition license. This tool provides simplified and automatic data guard maintenance and configuration procedures. How to use it I will describe later in this article.
Oracle Data Guard could be deployed among different platforms(x86, Power, Itanium, SPARC), Operating systems(32/64 bit) and Oracle software versions (32/64bit) with limitations.
Check This notes : 413484.1 and 1085687.1 On MOS.
Data Guard deployment examples
Examples provided here are using fast start failover technology for automatic failover operations.
Without fast start failover in place all failover operations must be performed manually.
The depiction of solution above demonstrates high level HA ready deployment leveraging fast start fail-over configuration and active data guard option on physical standby for reporting&queries.
Here observer is data guard broker executable utility, used in fast start failover configurations, which could run on either laptop, server or workstation.
Disaster ready setup
The depiction of solution below demonstrates high level DR ready deployment leveraging fast start failover configuration and logical standby for reporting&queries. As depicted it involves 3 different sites to provide desired functionality. Although it is not intended to provide reporting services in case of Site A outage, it could be done by putting additional standby server in site B though.
Standby databases overview
Data Guard provides three different types of standby databases:
- Physical standby. This is physically identical copy of primary database compared on block level. All database physical and logical structures like data files, schemas are the same. Standby database is synchronized through Redo Apply mechanism, which delivers redo data and applies it on the physical standby database. For such purpose so called standby redo logs are used in standby which are providing similar functionality as online redo logs.
- Logical standby. This type of database contains only the same logical information as the production database, but the physical structure of the data can be different, like different data file organization and etc. The logical standby database is synchronized through SQL Apply mechanism, which first transforms the data, in the redo received, into SQL statements – DML’s and DDL’s – and then executes them on the standby. Here LogMiner component of SQL Apply is used. Standby databases are functioning in read write mode.
- Snapshot standby. This type of physical standby database appeared first with 11g release. It is more like a data guard mode than a different configuration. The only difference from latter ones, when enabled it is fully operational – read and write mode – production database copy, where users can access and perform any data manipulations. Meantime redo data is being received from the primary database, archived, but not applied until snapshot standby database is reverted back to the physical standby database.
Physical standby
- Starting with Oracle database release 11g there is new active data guard feature which allows reporting and queries while redo apply is active on physical standby. This data guard option must be purchased as add-on to Enterprise edition license.
- Can be used to offload backup operations from production server.
- Supports all database datatypes, types of tables, DDL and DML operations
* Logical standby
- Typically is used for reporting and queries while sql apply is active on logical standby.
- Could be used for database upgrades with minimal downtime.
- Can maintain other database objects not belonging to primary database.
- Logical standby database has limitation on support of datatypes, types of tables, DDL and DML operations.
Data Guard protection modes
Databases running with Data Guard implemented could be configured to act differently when primary server outage is taking place.
Maximum performance
Default protection mode. This protection mode provides maximum protection without affecting primary database performance. Here transactions on primary are committed as soon as redo log is filled with all relevant redo data without waiting for write accomplishment from standby databases – it is being done asynchronously. Therefore such protection mode does not guarantee complete data restore until last transaction.
Maximum availability
This protection mode guarantees that no data loss will occur if primary database fails. Transactions do not commit until all relevant redo data is written in redo and standby redo logs of standby database. In such configuration standby database is kept completely synchronized with primary. In case of standby database outage or whatever reasons preventing to write/send redo data into standby locations, primary database is kept running to preserver availability.
Maximum protection
This protection mode guarantees that no data loss will occur if primary database fails. The only difference from the Maximum Availability mode is that if primary database cannot write/send redo data into standby database locations it will be shutdown. Since such configuration prioritizes data protection over primary database’s availability, the recommended deployment is to have at least several standby databases.
How to enable, change protection modes
from SQLPlus on primary :
ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE AVAILABILITY/PERFORMANCE/PROTECTION;
from Data Guard broker command line interface :
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY/MAXPROTECTION/MAXPERFORMANCE;
Thank you
Osama Mustafa
ORA-29701: Unable to connect to Cluster Manager
The reason is Oracle cssd daemon process was not running.
As Root User :
Step 1: Go to the /etc folder
Step 2: Execute the following command.
# init.cssd start
startup will be queued to init within 30 seconds
Step 3: Wait for 2 minutes and execute the following commands
# cd $ORACLE_HOME/bin
# ./localconfig delete
Stopping CSSD
Failure in CSS initialization opening OCR.
Shutdown has begun. The daemons should exit soon.
Step 4: Execute the following command
# ./localconfig add
Successfully accumulated necessary OCR keys.
Creating OCR keys for user root, privgrp ‘system’
Operation Successful
Configuration for local css has been initialized.
Adding to inittab
Startup will be queued to init within 30 seconds
Checking the status of new oracle init process..
Expecting the CRS daemons to be up within 600 seconds
CSS is active on these nodes
nodelist
CSS is active on all nodes
Oracle CSS service is installed and running under init(1M)
Step 5: Start the ASM instance now.
Drop all Triggers On Database
First One : ( For Specific User)
BEGIN
FOR i in (select trigger_name,owner
from dba_triggers
where trigger_name like '%_BI%' and owner = 'myTesting' ) LOOP
EXECUTE IMMEDIATE 'DROP TRIGGER '||i.owner||'.'||i.trigger_name;
END LOOP; END;
Second One : (For All Database)
BEGIN
FOR i in (select trigger_name,owner
from dba_triggers ) LOOP
EXECUTE IMMEDIATE 'DROP TRIGGER '||i.owner||'.'||i.trigger_name;
END LOOP; END;
Thank you
Osama Mustafa
ORA-1652: unable to extend temp segment by % in tablespace TEMP
This error is fairly self explanatory – we cannot get enough space for a temporary segment. The size reported in the error message is the number of contiguous free Oracle blocks that cannot be found in the listed tablespace.
How to approach the ORA-1652 error
There are two views in the database that help keep track of the free space in the temporary tablespace: v$sort_usage and v$tempseg_usage (from 9i onwards).
select TABLESPACE_NAME,TOTAL_BLOCKS,USED_BLOCKS,FREE_BLOCKS from v$sort_segment; TABLESPACE_NAME TOTAL_BLOCKS USED_BLOCKS FREE_BLOCKS
——————————- ———— ———– ———–
TEMP 1310592 0 1310592
If USED_BLOCKS = TOTAL_BLOCKS, find which user and statement is using the temporary sort segment by following;
SELECT a.username, a.sid, a.serial#, a.osuser, b.tablespace, b.blocks, c.sql_text
FROM v$session a, v$tempseg_usage b, v$sqlarea c
WHERE a.saddr = b.session_addr
AND c.address= a.sql_address
AND c.hash_value = a.sql_hash_value
ORDER BY b.tablespace, b.blocks
Conclusion
There are two ways of solving this error:
- Add more tempfiles, increase the size of the current ones or enable auto extend and the most important:
- Tune the queries/statements so that the sort operations are done in memory and not on the disk.
Thank you
Osama Mustafa
Get Database Parameters even Hidden One
First Query : (display all init.ora parameter including the hidden parameters):
SET linesize 235
col Parameter FOR a50
col SESSION FOR a28
col Instance FOR a55
col S FOR a1
col I FOR a1
col D FOR a1
col Description FOR a90SELECT
a.ksppinm “Parameter”,
decode(p.isses_modifiable,‘FALSE’,NULL,NULL,NULL,b.ksppstvl) “Session”,
c.ksppstvl “Instance”,
decode(p.isses_modifiable,‘FALSE’,‘F’,‘TRUE’,‘T’) “S”,
decode(p.issys_modifiable,‘FALSE’,‘F’,‘TRUE’,‘T’,‘IMMEDIATE’,‘I’,‘DEFERRED’,‘D’) “I”,
decode(p.isdefault,‘FALSE’,‘F’,‘TRUE’,‘T’) “D”,
a.ksppdesc “Description”
FROM x$ksppi a, x$ksppcv b, x$ksppsv c, v$parameter p
WHERE a.indx = b.indx AND a.indx = c.indx
AND p.name(+) = a.ksppinm
AND UPPER(a.ksppinm) LIKE UPPER(‘%&1%’)
ORDER BY a.ksppinm;
Second Query (list of parameter which are not default):
SET linesize 235 pagesize 200
col Parameter FOR a50
col SESSION FOR a28
col Instance FOR a55
col S FOR a1
col I FOR a1
col D FOR a1
col Description FOR a90SELECT * FROM (SELECT
a.ksppinm “Parameter”,
decode(p.isses_modifiable,‘FALSE’,NULL,NULL,NULL,b.ksppstvl) “Session”,
c.ksppstvl “Instance”,
decode(p.isses_modifiable,‘FALSE’,‘F’,‘TRUE’,‘T’) “S”,
decode(p.issys_modifiable,‘FALSE’,‘F’,‘TRUE’,‘T’,‘IMMEDIATE’,‘I’,‘DEFERRED’,‘D’) “I”,
decode(p.isdefault,‘FALSE’,‘F’,‘TRUE’,‘T’) “D”,
a.ksppdesc “Description”
FROM x$ksppi a, x$ksppcv b, x$ksppsv c, v$parameter p
WHERE a.indx = b.indx AND a.indx = c.indx
AND p.name(+) = a.ksppinm
AND UPPER(a.ksppinm) LIKE UPPER(‘%&1%’)
ORDER BY a.ksppinm) WHERE d=‘F’;
Scripts : Find Oracle Parameters
Find User with unlimited Tablespace Quota
SELECT username,tablespace_name, bytes, max_bytes
FROM dba_ts_quotas
WHERE max_bytes = –1 AND tablespace_name =‘SYSTEM’;USERNAME TABLESPACE_NAME BYTES MAX_BYTES
————————- ————————- ———- ———-
SCOTT SYSTEM 0 –1
TEST SYSTEM 0 –1
why do we want to know who has unlimited quota on the SYSTEM tablespace?
User who have unlimited quota on SYSTEM as well the privilege to create tables or clusters could do some kind of denial of service attack to the database. The just have to fill up the free space in the SYSTEM tablespace. If there default tablespace is as well SYSTEM the could even do this without intention.
Find user with system privilege UNLIMITED TABLESPACE.
SELECT * FROM dba_sys_privs WHERE privilege = ‘UNLIMITED TABLESPACE’
GRANTEE PRIVILEGE ADM
—————————— —————————— —
WMSYS UNLIMITED TABLESPACE NO
RRDOMREG UNLIMITED TABLESPACE NO
HR UNLIMITED TABLESPACE NO
OE UNLIMITED TABLESPACE NO
SYS UNLIMITED TABLESPACE NO
LOGSTDBY_ADMINISTRATOR UNLIMITED TABLESPACE NO
SCOTT UNLIMITED TABLESPACE NO
BI UNLIMITED TABLESPACE NO
OUTLN UNLIMITED TABLESPACE NO
DBSNMP UNLIMITED TABLESPACE NO
IX UNLIMITED TABLESPACE NO
SH UNLIMITED TABLESPACE NO
DBA UNLIMITED TABLESPACE YES
SYSTEM UNLIMITED TABLESPACE YES
What about cascaded roles?
Mmh, but since Oracle 11g it is possible to grant UNLIMITED TABLESPACE to a role and this can be granted to an other role which is granted again to an other role. It could be a role concept or somebody who want to hide a little bit some privileges. To test it I’ve created three roles DBA3, DBA2 and DBA1, granted UNLIMITED TABLESPACE to DBA3.
SELECT
grantee,
privilege,
DECODE(p,‘=>’||grantee,‘direct’,p) path
FROM (
SELECT
grantee,
privilege,
SYS_CONNECT_BY_PATH(grantee, ‘=>’) p
FROM (
SELECT
grantee,
privilege
FROM dba_sys_privs
UNION ALL
SELECT
grantee,
granted_role privilege
FROM
dba_role_privs)
START WITH privilege = ‘UNLIMITED TABLESPACE’
CONNECT BY PRIOR grantee = privilege )
WHERE
(grantee IN (SELECT username FROM dba_users)
OR grantee = ‘PUBLIC’);GRANTEE PRIVILEGE PATH
——— ———————– ——————————-
BI UNLIMITED TABLESPACE direct
SYS DBA =>DBA=>SYS
SYSTEM DBA =>DBA=>SYSTEM
SCOTT DBA1 =>DBA3=>DBA2=>DBA1=>SCOTT
SYS DBA1 =>DBA3=>DBA2=>DBA1=>SYS
SYS DBA2 =>DBA3=>DBA2=>SYS
SYS DBA3 =>DBA3=>SYS
DBSNMP UNLIMITED TABLESPACE direct
HR UNLIMITED TABLESPACE direct
IX UNLIMITED TABLESPACE direct
SYS LOGSTDBY_ADMINISTRATOR =>LOGSTDBY_ADMINISTRATOR=>SYS
OE UNLIMITED TABLESPACE direct
OUTLN UNLIMITED TABLESPACE direct
RRDOMREG UNLIMITED TABLESPACE direct
SH UNLIMITED TABLESPACE direct
SYS UNLIMITED TABLESPACE direct
SYSTEM UNLIMITED TABLESPACE direct
WMSYS UNLIMITED TABLESPACE direct18 ROWS selected.
create one to find user’s with direct quotas as well through a system privilege will give something like this.
SELECT
username,
tablespace_name,
privilege
FROM (
SELECT
grantee username, ‘Any Tablespace’ tablespace_name, privilege
FROM (
— first get the users with direct grants
SELECT
p1.grantee grantee, privilege
FROM
dba_sys_privs p1
WHERE
p1.privilege=‘UNLIMITED TABLESPACE’
UNION ALL
— and then the ones with UNLIMITED TABLESPACE through a role…
SELECT
r3.grantee, granted_role privilege
FROM
dba_role_privs r3
START WITH r3.granted_role IN (
SELECT
DISTINCT p4.grantee
FROM
dba_role_privs r4, dba_sys_privs p4
WHERE
r4.granted_role=p4.grantee
AND p4.privilege = ‘UNLIMITED TABLESPACE’)
CONNECT BY PRIOR grantee = granted_role)
— we just whant to see the users not the roles
WHERE grantee IN (SELECT username FROM dba_users) OR grantee = ‘PUBLIC’
UNION ALL
— list the user with unimited quota on a dedicated tablespace
SELECT
username,tablespace_name,‘DBA_TS_QUOTA’ privilege
FROM
dba_ts_quotas
WHERE
max_bytes = –1 )
WHERE tablespace_name LIKE UPPER(‘SYSTEM’)
OR tablespace_name = ‘Any Tablespace’;USERNAME TABLESPACE_NAME PRIVILEGE
————————- ————————- ——————————
…
SYSTEM Any Tablespace UNLIMITED TABLESPACE
SYS Any Tablespace DBA
SYSTEM Any Tablespace DBA
SCOTT Any Tablespace DBA1
SYS Any Tablespace DBA1
SYS Any Tablespace DBA2
SYS Any Tablespace DBA3
SYS Any Tablespace LOGSTDBY_ADMINISTRATOR
TEST SYSTEM DBA_TS_QUOTA19 ROWS selected.
You Can Download Script from here : Tablespace-scripts
Links :
1-Find TableSpace Quota .
Thank you
Osama Mustafa
Data Pump impdp expdp NETWORK_LINK option
New Features In 11g / ADRCI
What is It ?
diagnostic data such as traces, dumps, the alert log, health monitor reports, and more. It has a unified directory structure across multiple instances and multiple products. Beginning with Release 11g, the database, Automatic Storage Management (ASM), and other Oracle products or components store all diagnostic data in the ADR. Each instance of each product stores diagnostic data underneath its own ADR home directory. The ADR’s unified directory structure enables customers and Oracle Support to correlate and analyze diagnostic data across multiple instances and multiple products.
Contain :
adrci> show problem
adrci> show incident
adrci> show incident -mode detail -p “incident_id=”incident_id””
adrci> show trace “trace file name
adrci> ips create package problem 1 correlate all
adrci> ips generate package 1 in “/home/oracle”
adrci> show tracefile -rt
adrci> show control
SHORTP_POLICY :Retention for ordinary trace files
LONGP_POLICY :Retention for like incident files
adrci> set control (SHORTP_POLICY = 360) ===>15days
adrci> set control (LONGP_POLICY = 2160) ===>90 Days
adrci> show control
Following command will manually purge all tracefiles older than 2 days (2880 minutes):
adrci> purge -age 2880 -type trace
adrci> purge -age 129600 -type ALERT ===> purging ALERT older than 90 days
adrci> purge -age 43200 -type INCIDENT ===> purging INCIDENT older than 30 days
adrci> purge -age 43200 -type TRACE ===> purging TRACE older than 30 days
adrci> purge -age 43200 -type CDUMP ===> purging CDUMP older than 30 days
adrci> purge -age 43200 -type HM ===> purging HM older than 30 days
adrci> show tracefile -rt
1-ADRCI Tips

