Making the most of Oracle 18c XE – Pluggable Databases and the Oracle Eco-System

This was going to be a simple post about creating multiple Pluggable Databases (PDBs) in Oracle 18cXE.
But you know what it’s like, you get your lego database set out and then you spot those unusual shaped bricks… and the transparent ones… oh, that one has a wheel on…and get a bit carried away.
What follows is a guide on how to create three concurrent PDBs on an Oracle 18cXE database. However, I have taken the opportunity to investigate other areas of the Express Edition platform and so will be making use of Advanced Compression as well as Oracle Enterprise Manager Express.
In fact, I wouldn’t be surprised if SQLDeveloper put in an appearance as well.
I’ve also included a couple of the more notable members of Oracle’s small-but-perfectly-formed eco-system into the final design. On top of all that, I’ll be performing a magic trick to ensure that I only have to install each piece of software once, even though it may end up in multiple PDBs…
Continue reading

My Commute through London

Don’t worry. The title isn’t an oblique reference to something technical so I’m not going to let you get halfway down the page and then start writing some indecipherable computer code.
Also, if you happen to be my Dad, some of what follows may be familiar as you grew up around here.
If you’re not then you’re not obliged to laugh at any gags I’ve worked in because they’re mainly for his benefit.

We’re going to go on a quick (pre-lockdown) tour through history and legend, following the route of what, until fairly recently, was my daily commute across London before catching the train to Milton Keynes. More or less.
Look, to be completely honest we may be taking a couple of detours along the way. If your searching for the quickest route from Canary Wharf to Euston, well this may not be it.
Neither will we be paying too much attention to of some of the more famous landmarks that London has to offer.
Instead, we’ll be using the Tube Network to bounce back and forth through the centuries like a joyride in a TARDIS, taking a look at some of the City’s less obvious historical sites along the way.
Incidentally, if that idea does take your fancy, there’s a TARDIS parked in Earl’s Court Road.
Continue reading

Running a shell script from inside an Oracle database using DBMS_SCHEDULER

As I write, various parts of the United Kingdom are still under variations of the theme of “lockdown”. Not that I’m stir crazy or anything but I’ve now decided it’s time to explore one way of escaping, from the confinements of my database, at least.

Specifically I’m going to :

  • create an OS user on the database server
  • create an OS group to allow both the new user and the oracle user to access to a common location
  • create a shell script owned by the OS user which writes to that common location
  • create a credential to access that user from inside the database itself
  • setup and run a scheduler job to execute a shell script as the new OS user
  • read the output file generated by the shell script from inside the database

For this exercise, I’m using my trusty 18cXE database running on CentOS… Continue reading

To Boldly gzip from PL/SQL

Lempel-Ziv. Sounds like something you might find on a starship. I mean, you can just imagine Scotty telling Kirk that they can’t go to warp because the Lempel-Ziv compressors are offline.
In fact, the Lempel-Ziv algorithm is what GNU’s Gzip program uses to compress files.
Fortunately, the UTL_COMPRESS package employs the same algorithm, which means that you can create archives using one tool that can be manipulated by the other…
Continue reading

Secrecy and (file) Corruption – diving into the murky world of GPG encryption

Transferring sensitive data between systems often requires some for of encryption to ensure that the data is protected from prying eyes.
One common method of achieving this is to use Gnu Privacy Guard (GPG).
What I’m going to look at here is :

  • Creating GPG keys on a server
  • Using a Public Key to encrypt data on a different machine
  • Decrypting an encrypted message
  • Things to try if you get some of the more wacky GPG error messages

If you’ve stumbled on this post because of the last of these, you’re in good company. I’m sure someone initimately familiar with this tool will instantly know the meaning of the error message “Ohhhh jeeee: mpi larger than packet” but as far I’m concerned, it may as well have read “Divide by Cucumber Error”.
Hopefully, things will become clearer down the page…
Continue reading

Reading an OS file from inside an Oracle Database using an External Table

Two weeks into lockdown and some are looking to break the monotony by varying their diet…

For my part, I’ve decided to amuse myself by making a couple of “Top five” lists – the five best things about the lockdown and five things I’ve now finally got time to watch.

These lists are in text files are somewhere on my Database server and therefore provide the basis for the examples that follow.

When using Oracle, if you find yourself in a situation where you don’t have access to the Database Server file system, or would just rather use SQL to find what you’re looking for in a data set, you’re in luck.
The technique that used to be a neat way of viewing the database alert log from inside the database can now be re-purposed to look at any text file that’s located in a directory referenced by a Directory Object in the database.

What we’re going to look at here is :

  • Setting up an external table for reading from files
  • How to point the external table specific files and directories using EXTERNAL MODIFY
  • How achieve the same thing in 11gR2 databases with the help of DBMS_LOCK

First of all though, just in case you’re wondering….
Continue reading

Generating CSV files from PL/SQL the Very Easy Way.

This post is dedicated to Morten Braten and William Robertson.
Thanks to both of you for saving me a lot of time (and typing)…

XML, YAML, JSON. When it comes to transferring data between systems, they’ve all been flavour of the month at one time or another. However, good old CSV is still the format of choice when the batch window opens.
Not only is it simple, it adds comparatively little overhead to the size of the data file being generated.

OK – CSV used to mean “Comma-delimited” but these days it’s become synonymous with delimited data.
Whatever separator character you use, generating CSV is considerably easier these days…unless you’re using PL/SQL in a batch (as opposed to interactive) process.
That said, Connor MacDonald does have a clever way of utilising the functionality available in a command line tool such as SQL*Plus by means of a DBMS_SCHEDULER job.

If for some reason that won’t work for you, it looks like you’re going to have to hack out some custom PL/SQL to get the job done…or you could have a look at a couple of the options available in what other technologies would refer to as “the ecosystem”.
What I’m going to cover is :

  • The pain of hand-cranking delimited SQL
  • A solution offered in Morten Braten’s Alexandria PL/SQL Utility Library
  • An alternative solution made available by William Robertson
  • The final PL/SQL procedure
  • Continue reading

    Running a “background” job in PL/SQL

    Teddy has observed the recent General Election campaign with some interest and has concluded that he has what it takes to be the next Prime Minister.

    It’s not just the haircut, which does now look extremely Prime Ministerial…

    Politics is a robust business but Teddy’s more than capable of playing “ruff” :

    He firmly believes in the need to streamline Government at Cabinet level, which has the incumbent Chief Mouser to the Cabinet Office a little nervous.
    He’s also well used to being followed around by a “pooper scooper”. And not to put too fine a point on it, there’s more than one reason that he’s known as a “shaggy” dog.

    If he’s going to make it in politics, Teddy knows that he doesn’t have time to waste waiting for that pesky long-running job he’s just started. Oh no, he needs to use his evenings to get on with building his power base.
    Fortunately, Oracle facilitates detached execution of PL/SQL blocks by means of the DBMS_SCHEDULER package. Now, I know what you’re thinking, that’s going to involve a lot of fiddly setup with schedules and windows and chains and stuff. Well, you may be pleasantly surprised…
    Continue reading

    Upcycling and old TV to a Smart TV with an Amazon FireTV Stick

    Once upon a time, a TV was simply something you plugged into an arial socket and used to watch whatever broadcasters were prepared to show at any given time.
    With the rise of streaming, TVs have now become “smart”. Well, smartish. I mean, some of them use really slick software and have lots of Apps that enable you to stream from a variety of sources.
    Others are a bit less sophisticated and have limited access to such Apps.
    Not only that, the world is now full of the old type of “dumb” but perfectly serviceable TVs.
    So, if you want to :

    • Revitalise an old non-smart TV
    • Make a new not-so-smart TV smarter
    • Place a TV somewhere that’s not within easy reach of an arial socket

    …then help may be at hand. There are a number of devices you can plug into a TV to beef up it’s smartness.
    As these devices are streaming content over the internet, you don’t need an arial to make use of them.
    Furthermore, they are a fraction of the cost of buying a new Smart TV.

    What follows is an account of how I’ve setup an Amazon Fire TV Stick and used it to access the wealth of streaming content that’s freely available in the UK, as well as some of the main subscription services…
    Continue reading