SQL Adding a Column to an Existing Table

Since I can never remember the syntax to add a column to a table, here it is:

alter table foo_tablename add column foo_column int(10) default null

  • alter table – the actual command
  • foo_tablename – the table name we’re altering
  • add column – telling sql to add a column instead of some other alteration
  • foo_column – name of the column to add
  • int(10) default null – the column’s qualities (it’s an int up to 10 digits long, can be null and defaults to null

Tada!!!

Prankin’

People leave their macs unlocked. When they do, punish them in the most humane way possible =D

Setting Crontabs

Here are some of my favorites (setting a crontab is as easy as crontab -e):

Have their computer open their gmail inbox every 30 minutes. It’ll feel pretty random at first:

Or… every ten minutes, have their speakers verbalize something childish (yet HILARIOUS):

Scheduling jobs using at

at is a great little program. If you have a little time to work, feel free to create a bash script to do your bidding, then queue it as a job using at =]

Performance Issue Gut Check for MySQL

Sometimes MySQL performance can be difficult to hammer out. One of the quickest ways to get a good gut check is to have a look at the current process list. Check this out:

Now, this is relatively uninteresting, but sometimes, you’ll find a list of active queries that have stacked up against your db. Some things that can really help you identify issues is by ensuring each different piece of your platform identifies itself uniquely.

Once that happens, you can see which queries from where are hanging on. Parts of your platform can stall and hold onto connections, queries can take an eternity, bad code can hold result sets in memory, etc… This should give you a good idea where to start looking!

Hope this helps =]