MySQL: Display Width Of Integer Data Type

Sometimes junior database developers are being confused by field types like INT(2). Does it mean 2 bytes or 2 digits only?

However it is just optional field width which in conjunction with the optional extension attribute ZEROFILL allows to replace the default padding of spaces with zeros. For example, for a column declared as INT(5) ZEROFILL, a value of 4 is retrieved as 00004.

Therefore the display width does not constrain the range of values that can be stored in the column, nor the number of digits that are displayed for values having a width exceeding that specified for the column. For example, a column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range allowed by three characters are displayed using more than three characters.

But according to MySQL reference manual there is a possibility of problems when MySQL generates temporary tables for some complicated joins and larger values than the display width are stored in an integer column, because in these cases MySQL assumes that the data fits into the original column width.

2 Unlimited – Jump For Joy

Recently have discussed with a friend of mine that ‘2 Unlimited’ may be a good example of techno.

In any way jump for joy and… “Dance like no one is watching. Sing like no one is listening. Love like you’ve never been hurt and live like it’s heaven on Earth.” (Mark Twain)

By the way, Ray and Anita reunited on April 11, 2009, to perform together for the first time in 13 years at the “I Love The 90s” concert in Hasselt, Belgium.

MySQL: daylight savings time support

Time zone support is a typical part of many web applications. But not every application takes into account daylight savings time when +1 is added to hour difference during summer time only.

When PHP allows to identify DST simply by calling something like:

print date('I', strtotime('2009-03-11 00:00:00'));

it may not be obvious that:

SELECT CONVERT_TZ('2009-03-11 00:00:00', 'GMT', 'EST');

and

SELECT CONVERT_TZ('2009-03-11 00:00:00', 'GMT', 'US/Eastern');

return different results:

  • ‘2009-03-11 05:00:00’ in case of ‘EST’ and
  • ‘2009-03-11 04:00:00’ in case of ‘US/Eastern’.

This article explains how to make work CONVERT_TZ() function (which returns NULL by default) and stay current with time zone changes.

P.S.: There are some time zones with minute adjustment like UTC+5:45 or UTC+9:30 as well as with difference more than 12 hours from GMT like UTC+13 or UTC+14.

How to get sound from YouTube video

Sometimes it could be very convenient just to listen instead of sitting and watching. Especially if it is an interview or a lecture.

There is a very simple and fast service Media Converter which supports not only YouTube and allow to convert files up to 100Mb for free.

MySQL: Event scheduler is introduced in 5.1.6

Now MySQL allows executing tasks that run according to a schedule:

MySQL Events are tasks that run according to a schedule. Therefore, we sometimes refer to them as scheduled events. When you create an event, you are creating a named database object containing one or more SQL statements to be executed at one or more regular intervals, beginning and ending at a specific date and time. Conceptually, this is similar to the idea of the Unix crontab (also known as a “cron job”) or the Windows Task Scheduler.

Here is a sample SQL to create an event:

CREATE EVENT e_hourly
    ON SCHEDULE 
      EVERY 1 HOUR
    COMMENT 'Clears out sessions table each hour.'
    DO
      DELETE FROM site_activity.sessions;

Read more in MySQL reference manual: 19.4. Using the Event Scheduler as well as how this feature was originally designed by Andrey Hristov when he was working on his master’s thesis.

Evening Hail…

hail

P.S.: there were bigger ones…

MySQL: Mac OS Database Management

I’ve already written a post about MySQL GUI Tool for Windows.

In case you need to manage or support MySQL database on Mac OS X, Sequel Pro may be a good option. However it does not support stored routines manipulation. But hopefully it will be fixed in the next release.

sequel pro

Anticipate vs Expect

Anticipate means to expect and prepare for something when expect does not include the idea of preparation.

In other words “to expect” means looking forward to the outcome that you “should” get and “to anticipate” means looking forward to the outcome that you “want” to get.

For example:

  • We anticipate a large turnout at the next meeting.
  • He expects that you are tired from the trip.

Also there is a good quote from Dictionary.com:

Expect, anticipate, hope, await all imply looking to some future event. Expect implies confidently believing, usually for good reasons, that an event will occur: to expect a visit from a friend. Anticipate is to look forward to an event and even to picture it: Do you anticipate trouble? Hope implies a wish that an event may take place and an expectation that it will: to hope for the best. Await (wait for) implies being alert and ready, whether for good or evil: to await news after a cyclone.

Shortcut to open the right click context menu

It turned out that my new keyboard does not have the context menu key:
right click context menu

That’s why I was curious if there is any shortcut to open the right click context menu. Sometimes it is very convenient to be able to open context menu using keyboard. It was simple to find the right one.

The answer is: Shift+F10 (for Windows).

All roads lead to Rome

P.S.: next stop could be Athens. Who knows? 🙂

« Previous PageNext Page »