Latest articles under MySQL category

How to grant create database for non-root users

Introduction So here’s a recent requirement that I’ve just encountered. I have a shared MySQL database I have several users that I want them to be able to create new databases However, I don’t want them to see each other’s databases And just to be absolutely clear, I obviously don’t want to give them all […]

Posted on June 6th, 2014 under Database, MySQL  •  1 Comment

Swap values in 2 rows SQL

I encountered a situation at work that I feel would be a good brain teaser. I was working on a project and needed a way to swap values from 2 different rows in a SQL table. Obviously I can do it on client side (like PHP) to do it; but that wouldn’t be a good […]

Posted on October 11th, 2009 under General SQL, MySQL, PostgreSQL  •  16 Comments

Bulk alter schema in MySQL.

There are times when you want to alter schema for all tables in the database. For example, let’s say in your project you have multiple databases with multiple tables on each of them. Suppose that you have columns within that table defined as DECIMAL(11,6). What it means is that the column will have 11 digits […]

Posted on April 20th, 2009 under MySQL  •  1 Comment

Getting around MySQL TIMEDIFF() for hours greater than 838

One of the golden rule of programming is to know about the function you are calling. You need to know what parameters it takes and what return values and type it gives back. For the most part, it’s not too hard to find that out. For MySQL, however, I found that it’s not always easy […]

Posted on March 11th, 2009 under MySQL  •  12 Comments

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  •  6 Comments

Page 1 of 212