Assume all commands are being run on node 1, any commands that need to be run on node 2 will be explicitly stated. Any commands will be formatted in italics.
Archive for the ‘11g new features’ Category
Downgrading a RAC database from 11.2.0.4 to 11.2.0.3
Posted by John Hallas on May 4, 2017
Posted in 11g new features, Oracle | Tagged: 11.2.0.4 to 11.2.0.3, catdwg.sql, downgrade database | 4 Comments »
EXcellent blog post on SQL Profiles
Posted by John Hallas on July 5, 2016
Sometimes you across a blog entry and you think to yourself – ‘I wish I had written that’.
It is clear, it is on a subject you are interested in and the examples help illustrate the points clearly.
Well I did come across just such an article today. It was written by Franck Pachot and was on the subject of SQL Profiles
It was written 18 months ago and has only had 1800 hits. I think it deserves many more
Posted in 11g new features, 12c new features, Oracle | Leave a Comment »
Vote for “Create assertion” to be added
Posted by John Hallas on May 31, 2016
There is a standard for SQL code known as ANSI-92 which is adopted by many of the main RDBMS vendors. However each vendor has its own differences from the standard.
Oracle are currently taking votes on a proposal to add the CREATE ASSERTION statement to Oracle SQL on the OTN community page https://community.oracle.com/ideas/13028
Here are two examples of how the statement could be used
This SQL statement creates an assertion to demand that there’s no more than a single president among the employees:
create assertion AT_MOST_ONE_PRESIDENT as CHECK ((select count(*) from EMP e where e.JOB = 'PRESIDENT') <= 1 )
This SQL statement creates an assertion to demand that Boston based departments do not employ trainers:
create assertion NO_TRAINERS_IN_BOSTON as CHECK (not exists (select 'trainer in Boston' from EMP e, DEPT d where e.DEPTNO = d.DEPTNO and e.JOB = 'TRAINER' and d.LOC = 'BOSTON') )
To implement the same functionality now you would use a combination of check constraints and/or triggers.
I have cast my vote in favour
Posted in 11g new features | Tagged: ansi, check constraints, create assertion, sql-92, triggers | Leave a Comment »
ORAchk 12.1.02.5 is released – what does it offer ?
Posted by John Hallas on December 29, 2015
I have looked at the ORAchk tool before and thought that I must do something with it and I have now had a more detailed review of what it offers.
Firstly the history, it started off as RACchk and then morphed into ORAchk with a sibling called EXAchk. The recent release version is 12.1.0.2.5 which is available for MoS Doc_Id 1268927.2
It can perform an ever-growing list of checks against database, OS, specific applications (EBS and Peoplesoft being two)and various permutations of all that. It is very customisable, the usage command output runs to 281 lines !!
There is now the ability to run it as part of an Apex collection so that all reports can be centralised and you can then compare the differences between one run and the previous one.
Let me give an example of the ./orachk –b output. This shows the best practises and I have selected some of the output that seemed worthy of comment. Read the rest of this entry »
Posted in 11g new features, Oracle | Tagged: AWR_FLUSH_EMERGENCY_COUNT, exachk, hcve, health check verification engine, orachk, racchk, rda, session_cached_cursors | Leave a Comment »
Managing plans – identifying which plans have been used
Posted by John Hallas on December 7, 2015
This blog has the aim of answering quetions about how a sql statement has performed and which plan it has used. I have asked the type of questions that we as DBAs normally have to answer and shown how an answer may be arrived at.
We know the SQL_ID and we want to see what has been happening
set long 5000 lines 160 select sql_text from dba_hist_sqltext where sql_id = '7vt1xg0afxkba';
SQL_TEXT -------------------------------------------------------------------------------- INSERT INTO WC_INV_ITEM_DAILY_BAL_F(PRODUCT_WID,INVENTORY_PROD_WID,INVENTORY_ORG _WID,PLANT_LOC_WID,STORAGE_LOC_WID,INV_BALANCE_DT_WID,INV_BALANCE_TM_WID,UNIT_ST D_COST,VALUE_ONLY_AMT,VALUE_XFER_AMT,STD_COST_AMT,EXPIRATION_DATE,OBSELETE_QTY,D AYS_SINCE_EXPIRED,DAYS_LEFT_EXPIRY,DAYS_IN_INVENTORY,AVAILABLE_QTY,IN_TRANSIT_QT Y,INSPECTION_QTY,RESTRICTED_QTY,BLOCKED_QTY,RETURNED_QTY,REORDER_POINT,REPLENISH MENT_QTY,AVAILABLE_CONSIGN_QTY,INSP_CONSIGN_QTY,RESTRICTED_CONSIGN_QTY,BLOCKED_C ONSIGN_QTY,WIP_AMT,DOC_CURR_CODE,LOC_CURR_CODE,LOC_EXCHANGE_RATE,GLOBAL1_EXCHANG E_RATE,GLOBAL2_EXCHANGE_RATE,GLOBAL3_EXCHANGE_RATE,CREATED_BY_WID,CHANGED_BY_WID ,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ ON_DT,AUX4_CHANGED_ON_DT,DELETE_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ET L_PROC_WID,INTEGRATION_ID,TENANT_ID,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,X_CUSTOM,L
The SQL_ID is unknown but you do know some of the sql statement that will be used
select sql_id from dba_hist_sqltext where sql_text like 'INSERT%WC_INV_ITEM_DAILY_BAL_F%';
SQL_ID
————-
7vt1xg0afxkba
7052jrcrhfjbg
When did a sql statement run and what happened – did it use a different plan to normal Read the rest of this entry »
Posted in 11g new features, Oracle | Tagged: dba_hist_sqlstat, dba_hist_sqltext, dbms_xplan.display_awr, dbms_xplan.display_cursor | 1 Comment »
Why do you need to resetlogs after a cold backup restore
Posted by John Hallas on October 19, 2015
I posted a routine on how to take a cold backup locally to disk and then restore it back in 2010. Last week I was asked in a comment ‘why did you have to open the database using resetlogs?’ A very good question I thought so I proceeded to backup and recover just as the blog showed and I now know why.
Because Oracle will not let you do otherwise
Let me run through the example again and I will add a bit of commentary.
The original blog entry was https://jhdba.wordpress.com/2010/03/22/recovering-from-a-cold-backup-using-rman/
The basis of the commands were
startup nomount
run { allocate channel c1 device type disk format ‘/staging/oretail/KEEP_UNTIl_15APRIL2010/backup_db_%d_S_%s_P_%p_T_%t’; restore controlfile from ‘/staging/oretail/KEEP_UNTIl_15APRIL2010/backup_db_MOMPRE1A_S_37_P_1_T_713884663’; }
alter database mount;
run { allocate channel c1 device type disk format ‘/staging/oretail/KEEP_UNTIl_15APRIL2010/backup_db_%d_S_%s_P_%p_T_%t’; allocate channel c2 device type disk format ‘/staging/oretail/KEEP_UNTIl_15APRIL2010/backup_db_%d_S_%s_P_%p_T_%t’; restore database tag=’rman_backfulcold_MOMPREPERTEST’; }
–YOU DO NOT NEED TO RECOVER DATABASE otherwise it rolls forward to the current time
alter database open resetlogs;
As you can see I open the database with a resetlogs and yet it is a completely clean recovery and I should be able to do a noresetlogs. Read the rest of this entry »
Posted in 11g new features, Oracle | Tagged: backup controlfile, create controlfile, noresetlogs, ORA-01610, resetlogs | 5 Comments »
Using DBMS_PARALLEL_EXECUTE
Posted by John Hallas on August 13, 2015
DBMS_PARALLEL_EXECUTE
We have a number of updates to partitioned tables that are run from within pl/sql blocks which have either an execute immediate ‘alter session enable parallel dml’ or execute immediate ‘alter session force parallel dml’ in the same pl/sql block. It appears that the alter session is not having any effect as we are ending up with non-parallel plans. When the same queries are run outside pl/sql either in sqlplus or sqldeveloper sessions the updates are given a parallel plan. We have a simple test pack that we have used to prove that this anomaly takes place at 11.1.0.7 (which is the version of the affected DB) and at 12.1.0.2 (to show that it is not an issue with just that version).
It appears that the optimizer is not aware of the fact that the alter session has been performed. We have also tried performing the alter session statement outside of the pl/sql block i.e. in native sqlplus environment, that also does not result in a parallel plan
Let me show a test case Read the rest of this entry »
Posted in 11g new features, Oracle | Tagged: DBMS_PARALLEL_EXECUTE, DBMS_PARALLEL_EXECUTE.create_chunks_by_rowid, DBMS_PARALLEL_EXECUTE.create_task, PROCEDURE CREATE_CHUNKS_BY_SQL, user_parallel_execute_chunks | 5 Comments »
Migrating tablespaces across Endian platforms
Posted by John Hallas on August 13, 2015
This is a set of posts about migrating a database from one endian platform to another.
The long-term intention is to move a large (10Tb) 11.1.0.7 database on HP-UX to an OEL Linux server with minimum outage so that will include a database upgrade as well.
This first post is about migrating a self-contained set of schemas using transportable tablespace.
The HP-UX 11.1.0.7 database is called HPUXDB and it was created through dbca with the sample schemas created.. The target database is 11.2.0.4 on OEL 5.8
I already have an 11.2.0.4 installation on the OEL 5.8 server and the target database is called L18
Let’s check the endian versions
SELECT PLATFORM_ID, PLATFORM_NAME, ENDIAN_FORMAT FROM V$TRANSPORTABLE_PLATFORM; PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT 4 HP-UX IA (64-bit) 13 Linux x86 64-bit Little
Posted in 11g new features, ASM, Oracle | Tagged: change endian, cp datafile asm to asm, migrate tablespace, transportable tablespace | 1 Comment »
Identifying database link usage
Posted by John Hallas on September 28, 2015
As part of ongoing security reviews I wanted to determine if all database links on production systems were in use. That is not very easy to do and this article is a listing of some of the options I have considered to get that information and how it is now possible from 11GR2 onwards.
The first option was to look and see if auditing can be used. The manual states “You can audit statements that refer to tables, views, sequences, standalone stored procedures or functions, and packages, but not individual procedures within packages. (See “Auditing Functions, Procedures, Packages, and Triggers” for more information about auditing these types of objects.)
You cannot directly audit statements that reference clusters, database links, indexes, or synonyms. However, you can indirectly audit access to these schema objects, by auditing the operations that affect the base table.”
So you could audit activities on a base table that a database link might utilise, probably via a synonym. However that would show all table usage but it would be very difficult to break it down to see if a database link had been involved.
On the assumption that the code has a call to “@db_link_name” you could probably trawl ASH data or v$sql to see if a reference is available. It would be more likely that a synonym would be in use and as we have said above, we cannot audit synonym usage but you could maybe find it in v$sql. Again very work intensive with no guaranteed return.
There has been an enhancement request in MoS since 2006 – search for Bug 5098260
Jared Still posted a routine, although he does not claim to be the original author, which shows a link being actually used. However in reality that is not really a good way of capturing information across many systems unless you enable an excessive amount of tracing or monitoring across all systems. I have demoed usage of it below and it does work
I’ve created a DB link from SNAPCL1A to SNAPTM1. First I opened the DB link:
I can see my DB link being opened in v$dblink (in my own session):
The following script can be used to see open DB link sessions (on both databases). It can be executed from any session and it will only show open DB links (that have not been committed, rolled back or manually closed/terminated on the origin database):
On the origin database:
On the destination database:
Now, I rollback my session on the origin database:
If I query the v$dblink view, I still see my link there, but the transaction is closed now:
The script will not return anything at this point:
However since at least 11.2.0.3 Oracle have provided a better means of identifying database link usage after the event and not just during
Databases TST11204 and QUICKIE on different servers -both have dblinks to each other –
TST11204
At this point we have made a connection – lets see what we can find out about it. I would advise using the timestamp# column of aud$ to reduce the volume of data that has to be searched.
This information is in both source and target databases
It will return the source of a database link session. Specifically, it returns a string of the form:
SOURCE_GLOBAL_NAME=dblink_src_global_name, DBLINK_NAME=dblink_name, SOURCE_AUDIT_SESSIONID=dblink_src_audit_sessionid
where:
dblink_src_global_name is the unique global name of the source database
dblink_name is the name of the database link on the source database
dblink_src_audit_sessionid is the audit session ID of the session on the source database that initiated the connection to the remote database using dblink_name.
So hopefully that might help in identifying if a database link is still in use or when it was last used and it can be used as another part of your security toolkit.
Posted in 11g new features, Oracle | Tagged: aud$ comment$text, blink_src_global_name, comment$text, database link usage | 2 Comments »