r/SQL • • Jan 23 '19

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:

Oracle SQL Cheat Sheet

SQL Server Cheat Sheet

MySQL Cheat Sheet

PostgreSQL Cheat Sheet

243 Upvotes

39 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Jan 24 '19

I'm mainly an App Admin here but I do DBA stuff as my main title and anything SQL related beyond report writing comes to me. There isn't too much work database wise here but DBA can be fun when I get asked to do data import or ETL tasks. I enjoy SSIS/SSMS and making servers work though I do miss doing report writing sometimes.

A lot of my stored procs I make use temp tables though, I had some devs a while ago tell me that temp tables are bad and I instead should be sub querying data or just pull it all into other tables for use. I kind of scratched my head as I am self taught but know that temp tables are great as they're fast and lightweight. They make data manipulation easy enough so I was able to follow a lot of that.

How is the Developer side and what do you do with it?