Posts

Showing posts with the label sql

Schedule a job every 5 minutes with Oracle DMBS_JOB

For all those struggling to schedule a job every 5 minutes without drift here's a "simple" interval expression which can be easily adapted to other intervals (every 10 minutes, 20, etc): select sysdate, trunc(sysdate) + ( ( to_number(to_char(sysdate, 'HH24'))*60+floor(to_number(to_char(sysdate, 'MI'))/5)*5 + 5 ) / 1440) from dual; Btw, the espression is in the second column of the query.

Fun with Postgresql and ZFS

Image
I will show how to use ZFS instant snapshotting and cloning functionality to effortlessly clone a running postgres database regardless of its size. Setup Install your Linux OS of choice then ZFS and Postgres. I use Centos 7 but most commands used in this post are distro-indipendent. Create a zfs pool called tank or use whatever name suits you. In the pool create a filesystem called pgdata . For the sake of following a minimalist ZFS best practice apply the following settings: zfs set compression=lz4 tank/pgdata zfs set xattr=sa tank/pgdata

OTRS-hacking: log all sql queries for use in external reports

OTRS is a great ticket-tracking/helpdesk software. It even has cool statistics built in, but sometimes the PHB goes crazy and asks for impossibily detailed statistics. For those situations when the stats module cannot help us there a couple of (Open Source) tricks up our sleeve: install the Eclipse Birt web reporting application (we will need java and tomcat for that) create a custom report using the report designer deploy the report on the server and send the link to the boss To make sure the SQL queries used in the report are the same used by OTRS we can temporarily have OTRS log all queries (remember to disable logging after you're done or your log files will grow out of control) by editing the Kernel/System/DB.pm file as documented here : # 0=off; 1=updates; 2=+selects; 3=+Connects; # $Self->{Debug} = $Param{Debug} || 0; # leave the original around for later $Self->{Debug} = 2;

Automated conversion of MS-Access database to Postgres

Thanks to mdbtools it is now a little bit easier to migrate MS-Access databases to a newtork database like Postgres. This is a script that will bulk convert all the tables in a MS-Access database into a set of ready-to-use sql scripts (one per table).