Archive for the Database Category

Many times you will need to quickly executa a query in PostgreSQL and dump
the results to comma delimited value (CSV) file. In this post I’ll show you
a quick way to do it with the psql command in PostgreSQL.
Just copy the following to a file called dump2csv.sql

-- ==================================================================
--
--  This script will execute and SQL query using the psql
--  command and dump the results to a file called /tmp/result.csv
--
-- ==================================================================
--
-- Uses the following psql options:
--   \a toggle between unaligned and aligned output mode
--   \t show only rows
--   \o [FILE] send query results to file or |pipe
--
\a
\t
\pset fieldsep ,
\o /tmp/result.csv

-- query
select ..

To dump the result of the query to a file do:

$ psql -h -U -d -W -f dump2csv.sql

the result of your query will be stored in /tmp/result.csv.

RMan is Oracles de-facto backup and recovery application. It is used to backup the database files and archive logs. Sometimes an archive log might be mistakenly removed, moved or renamed from disk without following RMan’s backup retention policy. Since it is in the rman catalog it will try to make a backup of the missing archive log. This will cause rman to fail when it tries to make a backup of the archive log with the following error message:

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at <date>
RMAN-06059: expected archived log not found, lost of archived log compromises recoverability
ORA-19625: error identifying file <archive_log>
ORA-27037: unable to obtain file status

(more…)

  • english

One of our latest projects here in Easytech was done using PHP as our programming language and Oracle as our Database. We had a lot of experience coding in PHP and developing with the Oracle Database but none using both together. The project turned out to be a great one but there isn’t a lot of information on the web since most PHP applications use MySQL or PostgreSQL as their database. Today I was looking at what blogs where available on the Oracle site and came across Christopher Cross’s blog which has a lot of interesting information for PHP developers. In it I found links to two interesting presentations: “Leveraging the Power of Oracle with PHP: Taking Advantage of the Database” and ” PHP and Performance” and a link to a book called “The Underground PHP and Oracle Manual” written by Christopher himself and Alison Holloway which covers PHP and Oracle development. For more references on using PHP and Oracle visit the PHP section in the Oracle Technology Network.