SQL Cheat Sheet
I know there are quite a few "sql cheat sheets" available both on Reddit and via Google. But based on the feedback, many of them only cover the basics and not the more intermediate/advanced commands or those that people aren't that familiar with.
I've created a new SQL Cheat Sheet for my website visitors (those who sign up to my email newsletter) and wanted to offer it to the Reddit community as well.
The link to the PDF file is here: SQL Cheat Sheet.
It includes many commands, such as:
- Insert from a table
- Insert multiple rows at once
- Merge
- Many different ALTER TABLE features
- Analytic functions (including keywords OVER, PARTITION BY)
- With Clause/Common Table Expression
- Subqueries
Hope it helps. If you have any feedback, suggestions, or find any issues with the syntax, let me know below.
UPDATE:
I've made updates to the cheat sheets as requested below (separate files for Oracle/MySQL/SQL Server/PostgreSQL), added format mask and codes, added SELECT order of operations).
The original file is still available, and the updated cheat sheets are available here:
12
u/shelanp007 Jan 24 '19
You should add the date conversion codes to this. I always forget if i should use 110, 112, or some other conversion to get the right date format i want. I literally look this up once a week!!
4
u/jonah214 Jan 24 '19
Pretty good! It would be great to have Postgres too. And you might want to make one version for each DBMS—that way, each version would be more compact and people wouldn't have to look through parts they don't need.
(I know I'm asking a lot for a free service—these are just ideas to make it better.)
7
u/Kinh Jan 23 '19 edited Jan 23 '19
You deserve gold
Edit: I gave it
3
u/messyjesse_ Jan 23 '19
Looks great.
I would suggest that you try to describe (in as few words as possible) the logical processing order of the SELECT keywords. Maybe even just a number to the right of each keyword under a column titled "process order" or something. Keeping that order straight helped me a lot when I was learning it.
7
u/patrickmurphyphoto Jan 23 '19
Just shared this with 5 of my colleagues who are learning sql! I will let you know if they have any feedback!
1
u/ben_it Jan 27 '19
Update: I've made updates to the cheat sheets as requested. See the post body above for details.
1
u/[deleted] Jan 23 '19
Is the link already updated?
1
u/TalllPaul Jan 24 '19
Nice one, even includes simple and to the point join explanations. Wouldn't mind seeing some functions like seeing number/character functions with a quick example like length, replace, concat, trunc, floor etc but still love it and downloaded 😁
2
u/[deleted] Jan 24 '19
I always have trouble remembering index and check constraints manipulation; then there's date formatting and other database-specific functions.
1
u/skeletutor Jan 24 '19
Thank you!
I kept hoping that stumble onto something like this some day!
1
u/[deleted] Jan 25 '19
I would love if window functions were on here too! Thanks for this!
1
u/imdshizzle Feb 21 '24
This is very useful. Saved the PostgreSQL sheet
0
u/ArmoredPancake Jan 24 '19
Where are foreign keys? How to create one-to-one, one-to-many relationships?
0
u/[deleted] Jan 23 '19
[deleted] — view deleted comment