Author: Laurent Schneider

powershell goodies for Active Directory

What are my groups? PS> Get-ADPrincipalGroupMembership lsc | select -ExpandProperty “name” Domain Users oracle sybase Who is member of that group ? PS> Get-ADGroupMember oracle| select -ExpandProperty “name” Laurent Schneider Alfred E. Newmann Scott Tiger What is my phone number ? PS> (get-aduser lsc -property MobilePhone).MobilePhone +41 792134020 This works like a charm on your […]

in memory option

Oracle 12cR1 patchset 1 is due this month and there is a new parameter that you can set to boost your performance. It is a bit of a SET “_FAST”=true parameter. The in memory parameter is part of the sga. It is not mandatory to size it correctly, even if you do not have enough […]

fun with cron

Today I find out that my scheduler was too busy to execute all jobs in my crontab !? * * * * * (while :;do ssh example.com :; done) 59 23 19 06 * touch /tmp/bang my while loop is going to produce so much hangs on the cron deamon that it may not be […]

distinct listagg

One limitation in listagg, you cannot use DISTINCT. Okay, there are plenty of distinct-capable listagg workarounds, but to get the real listagg working, it is a bit of an headache With one listagg SELECT DEPTNO, LISTAGG (JOB, ‘,’) WITHIN GROUP (ORDER BY JOB) JOBS FROM ( SELECT DISTINCT DEPTNO, JOB FROM EMP) GROUP BY DEPTNO; […]

Index suggestion from the access advisor

Test case : create table t(x varchar2(8) primary key, y varchar2(30)); insert into t(x,y) select to_char(rownum,’FM00000000′), object_name from all_objects where rownum select * from t where x=00000001; X Y ——– —————————— 00000001 CON$ He received the expected data. Let’s check his plan SQL> explain plan for select * from t where x=00000001; SQL> select * […]

execute Sybase procedures from Oracle SQL Developer

Oracle SQL Developer provides access to data and code from other database systems than Oracle If you run Sybase procedures (or Microsoft SQL Server I suppose), you cannot use the BEGIN / DECLARE / EXEC in anonymous blocks begin print ‘HELLO’ end Error starting at line : 1 in command – begin print ‘HELLO’ end […]

Get the secondmax, again

Just bouncing on 2008/07/secondmax. Another way of getting secondmax would be with an ordered collection. While collection methods like (n), first, last, count are not in SQL, I used PLSQL (within SQL) WITH FUNCTION f (c sys.odcinumberlist, n NUMBER) RETURN number IS BEGIN RETURN c (n); END; SELECT f( CAST( COLLECT( CAST( sal AS NUMBER […]

Configure ORACLE_HOME for SQL Developer

The release V4.0 of sql developer is available for download : oracle.com/technetwork/developer-tools/sql-developer/downloads The doc is there : docs.oracle.com/cd/E39885_01/index.htm And read Jeff Smith twit’s and blog I requested some time ago a 64bit Windows version with JDK on Oracle SQL Developer Exchange and once again it got accepted. Okay, I have on my PC two Oracle […]

OracleContext as top object in Active Directory

When you do expand your Active Directory schema, it is not reversible; how to decide to use the OracleContext as a top object or not? On the one hand, for tnsnames resolution, you could hide your context down in your AD structure and change the path in ldap.ora DIRECTORY_SERVER_TYPE=AD DEFAULT_ADMIN_CONTEXT=”OU=Oracle,OU=Misc,DC=example,DC=com” For debugging, I set TNSPING.TRACE_LEVEL=ADMIN […]

Changing the log apply delay (DelayMins)

Whenever you change the DelayMins setting in Dataguard, you must remember it affects only logs that have not been shipped yet. DGMGRL> show database sDB01 delaymins DelayMins = ‘5’ DGMGRL> edit DATABASE sDB01 set property delaymins=2; Property “delaymins” updated ARC3: Archive log thread 1 sequence 3199 available in 5 minute(s) Tue Dec 03 15:34:59 2013 […]

sqlnet.ora, sqlplus.exe and tnsping.exe inconsistencies

if you use tnsping.exe and sqlplus.exe, the way the sqlnet.ora and tnsnames.ora are located differs Let’s take the following setup C:\tmp>type dir1\sqlnet.ora NAMES.DEFAULT_DOMAIN = (EXAMPLE.COM) NAMES.DIRECTORY_PATH = (TNSNAMES) C:\tmp>type dir1\tnsnames.ora db.example.com=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=srv1.example.com)(PORT=1521))(CONNECT_DATA=(SID=db01))) db.example.org=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=srv1.example.org)(PORT=1521))(CONNECT_DATA=(SID=db01))) C:\tmp>type dir2\sqlnet.ora NAMES.DEFAULT_DOMAIN = (EXAMPLE.ORG) NAMES.DIRECTORY_PATH = (TNSNAMES) C:\tmp>type dir2\tnsnames.ora db.example.com=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=srv2.example.com)(PORT=1521))(CONNECT_DATA=(SID=db02))) db.example.org=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=srv2.example.org)(PORT=1521))(CONNECT_DATA=(SID=db02))) You set TNS_ADMIN to dir1 and your current directory is dir2. […]

unreadable output file in powershell

If you redirect a not-completly-string output (like a spfile) to a file in powershell, you may not see the same in the file as in the output without redirection PS C:\> Select-String “compatible” .\spfileDB01.ora spfileDB01.ora:13:*.compatible=’11.2.0.4.0′ with redirection PS> Select-String “compatible” .\spfileDB01.ora > compatible.txt PS> vim -b .\compatible.txt ÿþ^M^@ ^@s^@p^@f^@i^@l^@e^@D^@B^@0^@0^@1^@.^@o^@r^@a^@:^@1^@3^@:^@*^@.^@c^@o^@m^@p^@a^@t^@i^@b^@l^@e^@=^@’^@1^@1^@.^@2^@.^@0^@.^@4^@.^@0^@’^@^M^@ ^@ With redirection and conversion to […]

multiconsumer Queue with an Oracle Type from Java

You have a multi consumer queue with a user defined type CREATE TYPE topic_message AS OBJECT(Subject VARCHAR2(30),Text VARCHAR2(80)) / BEGIN dbms_aqadm.create_queue_table( ‘topic_queue_table’, ‘topic_message’, Multiple_consumers=>TRUE); dbms_aqadm.create_queue( ‘toy_topic’, ‘topic_queue_table’); dbms_aqadm.start_queue( ‘toy_topic’); END; / You create the corresponding java class with JPublisher (check the documentation of Database JPublisher User’s Guide 12c Release 1 (12.1) from which I took […]

Change background of Oracle Entreprise Manager

If you have more than one OEM and want a red status bar in your production OEM, here the proceedings Stop your cloud control emctl stop oms -all Unzip the $MW/oracle_common/modules/oracle.adf.view_11.1.1/adf-richclient-impl-11.jar in a new directory $MW/jdk16/jdk/bin/jar -xvf $MW/oracle_common/modules/oracle.adf.view_11.1.1/adf-richclient-impl-11.jar edit the picture dbd_topShadow.png (for instance) in adf/images/fusion-11.1.1.3.0/dbd_topShadow.png and copy it to META-INF/adf/images/fusion-11.1.1.3.0/dbd_topShadow.png with your favorite picture […]

Monitoring details on your explain plan

We know how to generate an explain plan. SET AUTOT ON, the good old ambulance in Toad (which is no longer an ambulance those days), the explain plan button in SQL Developer or simply EXPLAIN PLAN create table t1 partition by hash(object_id) partitions 16 as select * from dba_objects; exec dbms_stats.gather_table_stats(user, ‘T1’) explain plan for […]

ODBC 32bits for Windows 64bits

Windows-On-Windows 64-bit (WOW64) enables you to run 32bits applications in 64bits OS. You will see there is another powershell, another registry, another ODBC tool, another Oracle client. %SYSTEMROOT%\syswow64\WindowsPowerShell\v1.0\powershell.exe First, we run powershell(x86) Get-itemproperty HKLM:\SOFTWARE\ORACLE\*| Select-Object ORACLE_HOME,ORACLE_HOME_NAME ORACLE_HOME ORACLE_HOME_NAME ———– —————- C:\oracle\product\11.2.0\client_32 client32bit_11203 Only the Oracle 32bit client is displayed cmd /c “%SYSTEMROOT%\syswow64\odbcconf.exe /a {configdsn “”Oracle […]

Oracle ODBC hello world with powershell

Demo : cmd /c “odbcconf.exe /a {configdsn “”Oracle in OraClient11g_home1″” “”DSN=helloworld|SERVER=DB01″”}” Create a helloworld data source connecting to your DB01 tns alias in your OraClient11g_home1 Oracle Home. It is easy to get the Oracle Home name with Get-itemproperty HKLM:\SOFTWARE\ORACLE\*| Select-Object ORACLE_HOME,ORACLE_HOME_NAME ORACLE_HOME ORACLE_HOME_KEY ———– ————— C:\oracle\product\11.1.0\client_1 OraClient11g_home1 C:\oracle\product\11.2.0\client_1 OraClient11g_home2 Then we create the connection (as […]

how to rename datafiles on standby

If you rename a file with alter database on primary, it will not occur on standby. If you want to rename it on standby to, you need to do it manually cancel the recovery (set dg_broker_start to false and restart db in mount status if you use dataguard) set the standby file management to manual […]