grant select on sys tables

I prefer to use a powerful named user with dba rather than sys. It is more conform to the security policies in place regarding accounting of administrator operations. Very occasionaly, my user get ORA-1031 insufficient privileges even if I have the dba role. Amoung others, I have “PURGE DBA_RECYCLEBIN” and DBMS_STREAMS_AUTH.GRANT_ADMIN_PRIVILEGE update, 2012-07-24 For purge […]

remove the current directory

Can I remove the current directory? I used to believe you cannot. Solaris: $ uname -s SunOS $ mkdir /tmp/bla $ cd /tmp/bla $ rm -r /tmp/bla rm: Cannot remove any directory in the path of the current working directory /tmp/bla $ AIX: $ uname -s AIX $ mkdir /tmp/bla $ cd /tmp/bla $ rm […]

American = fast

I had the incredible behavior of having the same query running 10x faster in sqlplus depending on two different PCs. After analysis, I realised the super fast pc was American… at least in nls_lang Slow client: PC setup in German, NLS_LANG is set to GERMAN_SWITZERLAND.WE8MSWIN1252 C:\>set NLS_LANG=GERMAN_SWITZERLAND.WE8MSWIN1252 C:\>sqlplus scott/tiger@db01 SQL*Plus: Release 11.2.0.3.0 Production on Fr […]

How to quit crontab -e without overwritting cron

Imagine my crontab * * * * * /usr/bin/date > /tmp/foo I am writing the date to /tmp/foo every minute $ cat /tmp/foo Thu Jul 5 08:45:01 CEST 2012 Now I want to view my crontab in my EDITOR (vi). $ crontab -e I do not quit yet. In the meantime, my colleague modify the […]

On deferred segment creation and truncate

One year ago, I wrote about a side effect of deferred segment creation and drop tablespace : on deferred segment creation Today I discoved one more side effect : In the good old days (I read once that you are old as soon as you start talking about the good old days) and according to […]

Check mount option in linux

I did not find a clean way to check the mount option in Linux. For instance wsize=32768 On AIX, I simply type “mount” and see the mount option… For some reasons, my Linux does not show me the complete mount options ! $ mount precision:/nfsserver on /nfsclient type nfs (rw,bg,addr=127.0.0.2) $ grep nfsclient /proc/mounts precision:/nfsserver […]

What does # mean in sqlplus?

The script used to be shutdown abort it has been replaced by #shutdown abort shutdown immediate Let’s try ! SQL> #shutdown abort ORACLE instance shut down. SQL> shutdown immediate ORA-01012: not logged on sqlplus just silently ignored the # symbol and executed the first statement. Thanks to Maxim comment, here is a new case to […]

[Hello World] run c# from powershell

How to run csharp code from command line with powershell. One line PS> add-type ‘public class c{public const string s=”hello world”;}’;[c]::s hello world You can also execute visual basic directly from powershell. PS> Add-Type -language visualbasic ‘public class v >> public const s as string = “Hello World” >> end class’ >> PS> [v]::s Hello […]

[Windows] Email of current user

I hate having to type my email address, so I created a long one-liner to do the trick of getting my email from Exchange and copying it in my clipboard powershell -noprofile -command “$o=New-Object DirectoryServices.DirectorySearcher; $o.SearchRoot=New-Object DirectoryServices.DirectoryEntry;$o.Filter=’samaccountname=’+$ENV:USERNAME;write-host ($o.FindOne().Properties.mail)” | clip save this as “C:\WINDOWS\E.BAT” Then, when you have to enter your email in a form […]

My first .NET gui in Powershell

I managed to interface Oracle and a GUI via powershell. First, load the Oracle and the .NET assemblies [void] [Reflection.Assembly]::LoadFile(“C:\oracle\product\11.2.0\client_1\ODP.NET\bin\2.x\Oracle.DataAccess.dll”) [void] [Reflection.Assembly]::LoadWithPartialName(“Drawing”) [void] [Reflection.Assembly]::LoadWithPartialName(“Windows.Forms”) Now, let’s retrieve EMP in a powershell array. I hope one of my reader will advise me on a better way 🙂 $connection=New-Object Oracle.DataAccess.Client.OracleConnection(“Data Source=DB01; User Id=scott; password=tiger”) $connection.open() $command=new-object Oracle.DataAccess.Client.OracleCommand(“select […]

EURO symbol, sqlplus, cmd.exe and various issues

One customer reported a not-correctly displayed Euro Symbol (€) in the database from sqlplus (msdos). Why? First, the character set did not support it. select * from v$nls_parameters where PARAMETER like ‘%CHARACTERSET%’; PARAMETER VALUE —————————— ————— NLS_CHARACTERSET WE8ISO8859P1 NLS_NCHAR_CHARACTERSET AL16UTF16 If you are still using WE8ISO8859P1, consider migrating to WE8MSWIN1252 using csalter sqlplus “/ as […]

Toad 11.5 is out

The latest Toad is now in production, 11.5, get it from http://toadfororacle.com. If you have an old license key, 9.6 or older, it may complain at installation time, just ignore. It will be fine at run time. Enhanced TAB browsing experience, nicer and more visible colors for your connection (production=red…), read-only connections. Currently it still […]

How to get rid of corrupted blocks without a backup

First, you identify the blocks in alert log or with db verify $ dbv BLOCKSIZE=8192 file=sysaux01.dbf DBV-00201: Block, DBA 12629823, marked corrupt for invalid redo application … DBVERIFY – Verification complete Total Pages Examined : 131072 Total Pages Processed (Data) : 69691 Total Pages Failing (Data) : 0 Total Pages Processed (Index): 28669 Total Pages […]

weekinmonth in powershell starts on Sunday…

This April month is full of surprises! Not only I did not have the opportunity to trick my colleagues on Sunday April first, but I had some bug of my code due to the start of the week. [int](get-date).dayofweek and (Get-WmiObject Win32_LocalTime).dayofweek both refer Sunday as day 0. PS> get-date Wednesday, 11. April 2012 18:31:52 […]

[alert] AIX Posix Timezone issue

Maybe you did get or you will get an issue with the date command in AIX. expected behavior, Linux $ TZ=NZST-12NZDT,M10.1.0/2,M3.3.0/3 date Sat Mar 17 00:14:54 NZDT 2012 $ TZ=Pacific/Auckland date Sat Mar 17 00:14:58 NZDT 2012 unexpected behavior, AIX $ TZ=Pacific/Auckland date Sat Mar 17 00:15:50 GMT+13:00 2012 $ TZ=NZST-12NZDT,M10.1.0/2,M3.3.0/3 date Fri Mar 16 […]

Powershell and dates

I wrote about unix timestamp i powershell. I wrote : It is chockingly easy ! but I should have written : … it is not correct 🙁 PS> ./perl -e “print time.’`n'” 1331454753 PS> get-date -u %s 1331458358.05694 there is about 3605 seconds difference. 1 hour for Europe/Zurich and 5 seconds to type on a […]

to ADO or to ODP ?

I just read on System.Data.OracleClient Namespace that System.Data.OracleClient are deprecated. The types in System.Data.OracleClient are deprecated. The types are supported in version 4 of the .NET Framework but will be removed in a future release. Microsoft recommends that you use a third-party Oracle provider. The alternative is to use ODP (from Oracle) instead of ADO […]

on Windows Management Instrumentation

I have a bit versed into powershell over the last months, I just cannot stop discovering new gems. Ex : Win32 Classes Self-explanatory examples : PS> (get-wmiobject win32_processor).currentclockspeed 3292 PS> (get-wmiobject win32_operatingsystem).version 5.1.2600 PS> (get-wmiobject win32_proxy).ProxyServer proxy.example.com PS> (get-wmiobject win32_proxy).ProxyPortNumber 8080 it goes on and on and on… the ways those things are accessible from […]

Unix timestamp in powershell

I was a bit playing with powershell. I wanted to know the week of month, day of weeks, and other gems. It is chockingly easy ! Unix Timestamp : PS> get-date -uformat %s 1329322194.18894 To get the day of week as number, you can chose between [int](get-date).dayofweek and get-date -uformat %u What does uformat stand […]

This system is for the use of authorized users only.

How to bypass the login banners? There is actually more than one banner to bypass. One of the them is the message of the day banner, commonly located in /etc/motd. Typically friendly, example in AIX **************************************************************************** * * * * * Welcome to AIX Version 6.1! * * * * * * Please see the […]

The new metalink interface

I just started using the New My Oracle Support User Interface It is a zero-flash interface with more capabilities than the “html” interface we used the previous years. It still provides about the same browser experience as the flash one. Have a try… according to Oracle : “it will eventually replace the Flash version” To […]

change system wide PATH variable in Windows

This is utterly simple and mostly you did it with the mouse. To do it with command line and powershell, proceed this way. Open a powershell window powershell or if you have no right to edit the machine-wide environment, runas admin runas /user:yourdomain\youruserplusadmin powershell then access the environment assembly [environment]::setEnvironmentVariable(“PATH”,”c:\oracle\product\11.2.0\client_1\bin;C:\WINDOWS\;C:\WINDOWS\system32;C:\Program Files\Putty;C:\Program Files\Perforce;C:\Program Files\TortoiseSVN\bin;C:\WINDOWS\system32\WindowsPowerShell\v1.0″,”MACHINE”) MACHINE is […]

Transport tablespace over db links

You do not want to export the metadata from the source database, but rather use a database link to get this. As prerequisite, you have made a set of self-contained tablespaces in read-only mode and you have copied the datafiles. SQL> create tablespace test datafile ‘/u02/oradata/db01/test01.dbf’ size 10m; Tablespace created. SQL> create table scott.x(x number) […]

Fast start failover

There are loads of things to do to prepare you for a fast start failover. First you must have a working set of primary / standby database Then you must have both databases in flashback mode. Then verify your dataguard configuration with OEM. Ok, once you are so far, you will need to review your […]

Failover to standby with a delay (until time)

Disaster scenario : 1) you have a primary database 2) you have a standby database 3) you want to be able to failover to the standby database until a given time (ex: within the last 24 hours) First, you create your primary and standby databases. If you have dataguard broker, you then set the DELAYMINS […]

Enterprise Manager command line interface

emcli has been around for a while, but in 12c the installation has never been easier do not search on otn for the jar, go to download with : Setup –>My Preferences –>Command line interface –> download install with : java -jar emclikit.jar client -install_dir=/u01/app/oracle/emcli configure with : emcli setup -url=https://precision.example.com:4901/em -username=sysman -password=sysmanpw -dir=/u01/app/oracle/emcli. That’s […]