MySQL Cheatsheet by Example
The MySQL Cheatsheet by Example includes samples of the most commonly used MySQL commands and queries. We have also included a summary of data types. For a more detailed explanation of how each data type should be used, see Using MySQL Data Types.
NEW Version 1.1 is Now Available
We just added the following to our free MySQL cheat sheet:
- 3 Way to Insert Rows
- How to Update a Row
- MySQL One-Line Commands
Download: MySQL Cheatsheet (32 kb) Downloads thus far: 1907
The cheatsheet is in Adobe Acrobat format.
This will be a "work in progress", so if you find any typos or have useful suggestions to share or think we need to add more examples, just leave a comment and let me know. This is an evolving project and the MySQL Cheatsheet will be updated periodically. The goal is to make it the most useful MySQL cheat sheet on the planet.






December 24th, 2007 at 9:29 am
MySQL Cheatsheet By Example
Tech-Evangelist has put together an excellent cheatsheet for MySQL. There’s lots of other MySQL cheatsheets out there, but this one is unique in the fact that it gives examples of usage rather than just snippets of code.
February 29th, 2008 at 4:54 am
I like your cheat sheet… It’s very nice and compact, and gives a good overview!
But as every Version 1.0, it’s not yet perfect.
Two things:
a) the integer data types range is not symmetric, ie. the range of tinyint is not +/-127 but -128 to +127! Smallint ranges from -32768 to +32767. This fact is related to the way the numbers are stored (for more info look for “two’s complement encoding” on the web)
b) You don’t mention the SET datatype
Best regards, Jakob
March 5th, 2008 at 5:57 pm
Now that is the type of constructive feedback I am looking for.
There is, however, a rationale behind the way I put the cheat sheet together. It is different because I’m trying to make it more practical than just a list of specifications.
a) I did not have enough room for large numeric ranges like that of BIGINT (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807), so I simplified the range. As a rule you should never use a numeric data type where the numeric values have any chance of exceeding the range limits.
b) I didn’t mention the SET data type because it is the most difficult to understand and I have never seen it used. The MySQL web site itself advises against using it. I could add some SET data type examples, but it may take a half of a page to explain how to use it.
Thanks again for the feedback. I may add SET to the next version. Perhaps there is someone who wants to use it. Obviously, you are one person who knows about it.
May 16th, 2008 at 12:56 pm
a) sounds reasonable…
b) The fact that I mentioned the SET datatype is because I found your cheat sheet when I was looking for a concise overview of the MySQL Data Types. I was looking for an exhaustive list to quickly check I didn’t forget any datatype that my code could have problems with.
But I agree with you, for most applications the SET datatype is not practical - especially because it effectively stores data in the CREATE TABLE statements. And that totally goes against database normalisation.
Best Regards!
May 17th, 2008 at 6:30 am
Hi Jakob
After you drew attention to it, I recently run into a couple MySQL update scripts where the SET datatype was used. I may add it to the next version of the cheat sheet, and add a separate article explaining its use for those who are curious.
Thanks for the response.
June 4th, 2008 at 8:55 am
INSERT might also be included.
June 24th, 2008 at 5:07 pm
Thanks a lot for the great cheatsheet! I’m a beginner and will surely benefit from it. I’ll look out for an updated version.
Any other cheatsheets you’re considering adding?
June 26th, 2008 at 5:28 am
Hi WFB
It will be in the next version, along with a lot of other suggestions that I have received. The next version should be ready soon.
Hi hotshot309
There are CSS, FileZilla and other cheat sheets in the works. All it takes it takes is the time that I don’t have right now. *sigh* :/
September 1st, 2008 at 2:45 pm
Version 1.1 of the MySQL cheat sheet is posted. It has the additions people requested.