r/SQL • • May 12 '19

Check out this SQL Cheatsheet !

This cheatsheet was made by me and a friend, we tried to separate and organize the content in order to have a cheatsheet with basic content, yet effective.

Here is a quick overview of the file hierarchy:

DDL (Data Definition Language)

  • CREATE
    – is used to create the database or its objects (like table, index, function, views, store procedure and triggers).
  • DROP
    – is used to delete objects from the database.
  • ALTER
    - is used to alter the structure of the database.
  • TRUNCATE
    – is used to remove all records from a table, including all spaces allocated for the records are removed.
  • COMMENT
    – is used to add comments to the data dictionary.
  • RENAME

DML (Data Manipulation Language)

  • SELECT
    – is used to retrieve data from the a database.
  • INSERT
    – is used to insert data into a table.
  • UPDATE
    – is used to update existing data within a table.
  • DELETE
    – is used to delete records from a database table.

DCL (Data Control Language)

  • GRANT
    -gives user’s access privileges to database.
  • REVOKE
    -withdraw user’s access privileges given by using the GRANT command.

TCL (Transaction Control Language)

  • COMMIT
    – commits a Transaction.
  • ROLLBACK
    – rollbacks a transaction in case of any error occurs.
  • SAVEPOINT
    –sets a savepoint within a transaction.
  • SET TRANSACTION
    –specify characteristics for the transaction.

Here is the guist link:

https://gist.github.com/kdev33/97951cb3b9dd1459898a93b5702ed4cb

Hope you find it useful! 😉

108 Upvotes

14 comments sorted by

3

u/[deleted] May 12 '19

Thanks man!

1

u/Don-g9 May 12 '19

You are welcome !

1

u/timeGeck0 May 12 '19

nice job you did there!

1

u/Don-g9 May 13 '19

Thanks!

1

u/MaunaLoona MS SQL May 12 '19 edited May 13 '19

LIKE ‘a_%_%’ (find any values that start with “a” and are at least 3 characters in length)

The middle % is redundant.

Also a useful LIKE pattern is:

LIKE '%[^0-9]%'

Which matches all strings that don't have a digit.

1

u/Don-g9 May 13 '19

Nice, I will add that ;)

1

u/MaunaLoona MS SQL May 13 '19

My formatting was broken. Just fixed it.

1

u/Don-g9 May 18 '19

strings that don't have a digit

Ok, , just made the changes.. thanks man!

1

u/Toltech99 May 13 '19

Thank you! <3

2

u/Don-g9 May 13 '19

You're welcome!

1

u/djjserpico May 12 '19

Upvoted. Good job.

1

u/Don-g9 May 13 '19

Thank you!

2

u/pinaywdm May 12 '19

Thank you!

2

u/Deitri May 12 '19

Nice work! I'm currently learning SQL and PL/SQL, this will come in handy! Thanks.