Monthly Archives: March 2009

How to create a TIMESTAMP/DATETIME column in MySQL to automatically be set with the current time

The TIMESTAMP data type is the only way to have MySQL automatically set the time when a row was inserted and/or updated. DATETIME columns can’t do this. TIMESTAMP columns are identical to DATETIME columns with one important exception — they … Continue reading

Posted in mysql | Tagged , | 13 Comments

MySQL Integer sizes and ranges of values – How-To Create Table example

There are 5 different integer columns, each hold integer values of different sizes. Moreover, each can be signed or unsigned. If your value can’t ever be negative (for example, for an index), then you should probably make your values unsigned. … Continue reading

Posted in mysql | Tagged , , | Leave a comment

How-To MySQL CREATE TABLE Example showing default values, NULL values and comments

This example shows how to set default values for each column — as well as how to allow (or not allow) NULL values in the column. By default, any column can contain NULL values. (Note that we’re also using “CREATE … Continue reading

Posted in mysql | Tagged , , | 8 Comments

Basic How-To Example of a MySQL CREATE TABLE command

Here’s a basic example of a MySQL CREATE TABLE command. CREATE TABLE `foo`.`example_01` ( `field_1` VARCHAR(255), `field_2` CHAR(10), `field_3` INT(10), `field_4` BIGINT(20), `field_5` DATETIME ); Notice that the ‘back tic’s on each column definition (the little ` characters) are optional … Continue reading

Posted in mysql | Tagged , , | 1 Comment

How to get the contents of the database.yml file from ActiveRecord

Save to delicious. Sometimes when using Active Record you may want to create a database connection to a database other than the default database specified in your database.yml file. When this happens, the easiest way to do it is to … Continue reading

Posted in ruby on rails | Tagged , , , , | 1 Comment

The future of programming? To provide the means for creating innovation.

I recently ran across an Information Week article called The Future of Programming that forecasts a drop in the demand for programmers along with a drop in their stature withing companies. They described off-shoring and the fall-off of the Internet … Continue reading

Posted in management | Tagged , , | 5 Comments

A Simple Example of a MySQL Stored Procedure that uses a cursor

(Save this to!) What is a cursor and when should you use one? A ‘cursor’ in MySQL is essentially just the result set that’s returned from a query. Using a cursor allows you to iterate, or step through, the … Continue reading

Posted in mysql | Tagged , | 40 Comments