Author: Laurent Schneider

Free blogging

Back in early 2005 I started this blog on Blogspot. Not being unserious about blogging, I bought this domain later in 2006 with paid hosting. I can recommend my GoDaddy provider for their support and attractive rates, but nowadays, I am no longer an active blogger. I’ll keep posting things occasionally on laurentschneider.wordpress.com. Saad posted […]

Identified by values reloaded

To get the correct values string, here is another approach, when you have no access to sys.user$ select username, extractvalue( xmltype( dbms_metadata.get_xml(‘USER’,username)), ‘/ROWSET/ROW/USER_T/SPARE4_12/text()’) from dba_users; USER SPARE4_12 ———– ————————- SCOTT S:12345678…;T:FEDCBA… OPS$ORACLE SYSTEM S: XS$NULL S:00000000… I would then ignore users with empty strings or S:00000000% or S: strings For Scott, then use alter user […]

Pretty JSON in 21c

Oracle 21c now enables JSON as a datatype 12.2, 18c, 19c: SQL> SELECT json_object(*) from scott.emp where ename=’SCOTT’; JSON_OBJECT(*) ————– {“EMPNO”:7788,”ENAME”:”SCOTT”,”JOB”:”ANALYST”,”MGR”:7566,”HIREDATE”:”1987-04-19T00:00:00″,”SAL”:3000,”COMM”:null,”DEPTNO”:20} 21c: SQL> SELECT json_object(* returning json) from scott.emp where ename=’SCOTT’; JSON_OBJECT(*RETURNINGJSON) ————————— {“EMPNO”:7788,”ENAME”:”SCOTT”,”JOB”:”ANALYST”,”MGR”:7566,”HIREDATE”:”1987-04-19T00:00:00″,”SAL”:3000,”COMM”:null,”DEPTNO”:20} Ok, it looks similar, but it’s a no longer a string (varchar2 or clob), it is a json object. SQL> create […]

checksum of a column

Something I always wanted arrived this week, a checksum of a column ! SQL> create table t1(x number); Table created. SQL> create table t2(x number); Table created. SQL> insert into t1(x) values (1); 1 row created. SQL> insert into t2(x) values (1); 1 row created. SQL> select (select checksum(x) from t1)t1, (select checksum(x) from t2)t2 […]

Database link and user defined datatypes

To use an object table or an object column over a database link, a type with the same OID as remote type must exist locally. SQL> conn user1/***@remotedb01 Connected. SQL> create type tt as object (x number) 2 / Type created. SQL> create table t (x tt); Table created. SQL> insert into t values (tt(1)); […]

Inline editting

I come from a no-tempfile world, where you getc and putc When moving from legacy Unixes to Linux, inline editting became legend. Number of utilities like sed can now edit the file without tempfile. Your AIX sysadmin probably used to do sed “s/xxx/yyy/” /etc/importantfile > /tmp/importantfile mv /tmp/importantfile /etc which works… BUT it has a […]

grep color

When you move away from commercial UNIX to Linux, some goodies are just fun, even if they are simple and old. Let’s look at grep. By default, the matched pattern is red. But the color could be changed. Some magic regexp could be used to get more than one color $ tnsping DB01 |    […]

cannot open database in NOARCHIVELOG

SQL> shu immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount quiet ORACLE instance started. Database mounted. SQL> alter database noarchivelog; Database altered. SQL> alter database open; alter database open * ERROR at line 1: ORA-00258: manual archiving in NOARCHIVELOG mode must identify log First time I see this. Let’s try to […]

ipcalc in powershell

Last day I wrote how to do it in AIX or Linux ip calc with ifconfig It isn’t that different in PowerShell, the fun is to the calculation yourself. For translating 0.0.0.0 in 0, we can use [IPADDRESS]. Let’s try… $ip = [IPADDRESS]( (Get-NetIPAddress -AddressFamily “IPv4” -InterfaceAlias “Ethernet*”). ipaddress) $prefix = ( Get-NetIPAddress -AddressFamily “IPv4” […]

sqlplus: error while loading shared libraries: libsqlplus.so: wrong ELF class: ELFCLASS64

This error usually while you do something wrong. Wait, what’s an error when you do everything right? Okay, here it is: You install the instantclient 32 rpm oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64 On that server, you switch home using oraenv $ . oraenv ORACLE_SID = [oracle] ? DB01 The Oracle base has been set to /u01/app/oracle You start sqlplus […]

ODBC and EZCONNECT or my way out of active directory

The traditional way of connecting Excel (or Access) to Oracle (and other databases) is to use ODBC and TNSNAMES. You install an Oracle client, you create a connection and specify your tnsnames connection alias as server, here below DB01 tnsnames.ora DB01 = (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP)(host=srv01)(Port=1521) ) (CONNECT_DATA= (SERVICE_NAME=DB01) ) ) But the file is often […]

Connect to ActiveDirectory with ldapsearch on Unix

In ancient times, ldapsearch could query ActiveDirectory without issues. In this examples, I used openldap client 2.4. Other tools may have other parameters. $ ldapsearch -H ldap://example.com:389 -b dc=example,dc=com cn=”Laurent C. Schneider” mail mail: [email protected] In Active Directory (AD) it is no longer the default since Windows Server 2003, unless you change dSHeuristics to 0000002 […]

free Oracle cloud forever

I could not miss this ! After offering free apex for non-productive usage (apex.oracle.com), free sql environment for playing (livesql.oracle.com), Oracle now offers free for ever infrastructure and database. With a few clicks, a credit card (that won’t be charged) and a few minutes of patience, you will be able to have your own Linux […]

Goldengate 19c on AIX for Oracle database

Now Oracle Goldengate 19.1.0.2 can manage 19c AIX Oracle DB instance. Linux has been out for a long time. Sparc is also available. For Windows, HPUX, patience … download.oracle.com $ ggsci Oracle GoldenGate Command Interpreter for Oracle Version 19.1.0.0.2 OGGCORE_19.1.0.0.0_PLATFORMS_190823.0013_FBO AIX 7, ppc, 64bit (optimized), Oracle 19c on Aug 25 2019 22:10:20 Operating system character […]

Dump TNSNAMES.ORA from ActiveDirectory

Having all connections string in ActiveDirectory is nice, but maybe you need sometimes to push it to an external system (e.g. DMZ or Linux). echo “# AD” > tnsnames.ora $o = New-Object DirectoryServices.DirectorySearcher $o.Filter = ‘objectclass=orclNetService’ foreach ($p in $o.FindAll().Properties) { [String]($p.name+”=”+$p.orclnetdescstring) >> tnsnames.ora } goodies

on logical and physical working directories

many ignore the difference meaning of .. (dot dot) as an argument when used with ls or cd this leads to buggy coding and wrong parsing of arguments in scripts let’s start with an example $ mkdir $HOME/test $HOME/test/physical $HOME/test/foo $ cd $HOME/test/foo $ ln -s ../physical logical $ cd logical $ ls -l .. […]

Oracle 18c/19c and ActiveDirectory

With Oracle 18c and even better in Oracle 19c, you can manage your Oracle database users in Active Directory. This was supposed to be a very nice new feature as many of us struggle with many thousand users spread over many versions, environments, platforms and even cloud or exadata. Is this going to help you? […]

Select from cdb_* views

There is no privileges strong enough for you to view all objects in all databases Let’s try as sys: SQL> select con_id, count(*) from cdb_objects group by con_id; CON_ID COUNT(*) ———- ———- 1 22749 3 22721 as non-sys SQL> create user c##u identified by ***; User created. SQL> grant create session, select any dictionary to […]

Standard date format

Let’s start with Powershell Get-Date -format “o” 2019-03-08T17:41:02.7346332+01:00 The “O” or “o” standard format specifier represents a custom date and time format string using a pattern that preserves time zone information and emits a result string that complies with ISO 8601 docs.microsoft.com Now Linux date “+%Y%m%dT%H:%M:%S.%3N%z” In SQL to_char(current_timestamp, ‘YYYYMMDD”T”HH24:MI:SS.FF3TZH:TZM’) for my XML fans extractvalue(xmlelement(t, […]

Audit pluggable database

In the old now-deprecated maybe-soon-desupported non-cdb infrastructure, AUDIT’ing was done right after connect / as sysdba. In single-tenant (or multi-tenant), things get complicated. Once again, the doc must be read at least twice 😉 If you issue an audit statement in the root, then the database performs auditing across the entire CDB, that is, in […]

19c

19c is a mini-release. Remember it is a new name for the second 12cR2 patchset, after 12.2.0.2/18c https://mikedietrichde.com/2019/02/13/oracle-database-19-2-for-exadata-is-now-available-for-download/ was the first to mention it. By looking up in the doc I found . Distinct listagg . Desupport sqlplus product profile . listener.log log rotation Go to the doc to find more https://docs.oracle.com/en/database/oracle/oracle-database/19/whats-new.html