Latest articles under Database category

Comparing data from 2 database tables

During development cycle, I often come to a case where I need to compare two tables whether they are the same or not. For example, if you already have a running script that outputs to a database table in production that was written sub-optimally and you need to improve it. You want to make sure [...]

Posted on March 1st, 2009 under General SQL, MySQL, PostgreSQL  •  5 Comments

Adding script name on SQL queries

Have you ever done SHOW FULL PROCESSLIST on MySQL and found that there are some queries that has been running for a long time? Then you tried to find out from where the query was initiated so that you can debug those script only to find out that there are many similar queries from different [...]

Posted on February 10th, 2009 under General SQL, PHP  •  1 Comment

Keep replication in mind when writing SQL code.

This is something I got "bitten" once, especially if you have a development server with its own database not replicated and production database is replicated. That slight difference is enough to cause production problems that may not be noticeable days after production release. As a wise man say:
When programming SQL statements, be mindful of replication.
Well, [...]

Posted on February 8th, 2009 under General SQL, Quick Tips  •  No Comments

Emulating nextval() function to get sequence in MySQL

There are times when auto increment is not sufficient. And there are times when what you need is actually a sequence. Unfortunately MySQL doesn’t have support for sequence. Having been working on PostgreSQL database as well, I found that it’s nextval() function is pretty nice. So in this article, I’d like to emulate (or implement) [...]

Posted on February 8th, 2009 under MySQL  •  11 Comments

Floyd-Warshal algorithm in PostgreSQL PL/pgSQL.

This article is an extension of my previous article This time, however, I will write the algorithm completely in PostgreSQL’s PL/pgSQL. For background information and to understand the premise of this post, please glance through my previous post.
Ok now that you’re familiar with what we’re working towards, here’s my assumption of your database structure:

You have [...]

Posted on January 24th, 2009 under General / Algorithm, PostgreSQL, Programming  •  No Comments

Page 2 of 3«123»