Posts Tagged ‘MySQL’

Once and for all: Rails migrations integer :limit option

August 20th, 2009

I literally always have to look up the meaning of :limit in migrations when it comes to integer values. Here’s an overview. Now let’s memorise it (oh, this works for MySQL, other databases may work differently):

Export CSV directly from MySQL

November 27th, 2008

How ofter were you asked by a client for a CSV (or excel) file with data from their app? I get asked that question quite often, so I wanted make the process as easy as possible. And guess what? You can create CSV files directly from MySQL with just one query!

MySQL: (Re)set the auto-increment value of a table

November 30th, 2007

Sometimes it’s necessary to set the starting point of a MySQL auto-increment value.

Normally, MySQL starts auto-incrementing at 1. But let’s say you want to start at 10.000, because you want at least a five figure number. You can use the following query to set the MySQL auto-index:

ALTER TABLE some_table AUTO_INCREMENT=10000

Find and Replace with a MySQL Query

June 10th, 2007

There are times when you have a lot of data in a database (let’s say wp_posts for a Wordpress blog like Ariejan.net). When you need to find and replace certain strings, this can be a very tedious task. Find all posts containing the “needle” string and manually replace all these occurrences with “chocolate”. With about 200 posts, you can imagine how long this would take to do manually.