Aaron Profile picture
Aug 2, 2021 β€’ 10 tweets β€’ 3 min read β€’ Read on X
Learn 3 commands used to control SQL transactions.

A Thread πŸ‘‡
First, what are transactions?

Transactions essentially group tasks into a single execution unit. If any of these tasks fail, the transaction is cancelled. Image
Transactions typically have 4 properties, which fall under the acronym ACID.

Each of these properties should be achieved for a database to be considered reliable. Image
To control these transactions, there are certain commands that can be used in SQL. Let's look at:

-- COMMIT
-- ROLLBACK
-- SAVEPOINT
The COMMIT command is for saving every transaction to the database

Below we delete rows where location is equal to "UK".

We then run COMMIT to ensure the changes are visible to other users Image
The ROLLBACK command will undo transactions that haven't been saved to the database since the last COMMIT or ROLLBACK command was run.

Here we delete some records, then immediately undo the changes. Image
The SAVEPOINT command is like a backup.

A SAVEPOINT is a point in a transaction to which you can later roll back. This avoids the need to rollback the entire transaction.

Here we are creating a SAVEPOINT and giving it a name. Image
If we want to ROLLBACK to a SAVEPOINT, we can run the following: Image
And that's all!

I actually forgot to include these in my cheatsheet, even though they're pretty important, so hopefully this gave you an of them.

Thanks for reading :)
*idea

I shouldn't tweet when I'm tired 😴

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Aaron

Aaron Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @AbzAaron

Aug 1, 2022
If you'd like to improve your SQL, here's some things to look into

β€’ CTEs
β€’ CASE WHEN with SUM
β€’ Window Functions
β€’ Logical Processing Order
β€’ Query Optimisation
β€’ Indexing
β€’ Database Design
β€’ Transactions
β€’ Correlated Subqueries
β€’ Self Joins
β€’ Set Operators
β€’ Views
Resource for Window Functions
postgresqltutorial.com/postgresql-win…
Read 12 tweets
Sep 5, 2021
Python has a lot of String Methods!

It's worth getting familiar with these πŸ™‚
Higher res PDF version here if anyone's interested
github.com/ABZ-Aaron/Chea…
Glad twitter is liking this! It's currently sitting at 1 like on LinkedIn lol
Read 4 tweets
Sep 3, 2021
Found out my SQL cheatsheet went viral on LinkedIn

Some people have actually covered up my name so they can pass it off as their own lol

Why do people do this? πŸ€·β€β™‚οΈ Image
I actually need to create a Version 2 of this. Completely forgot to include INSERT and a few other things first time around!
Also why cover my name up with sunglasses? Such a random choice πŸ˜…
Read 5 tweets
Aug 16, 2021
10 useful operations in SQL.

A Thread πŸ‘‡
Quick Note πŸ™‚

1. To run some of these operations, you'll likely need certain admin rights within your organisation

2. Always consult DBMS (database management system) documentation, as syntax will differ between DBMS
1⃣ CREATE DATABASE

Databases are essentially containers used to store organised data electronically, usually controlled by a database management system (DBMS)

Creating one is simple πŸ™‚
Read 13 tweets
Aug 12, 2021
20 useful tricks & tips in Python.

A Thread πŸ‘‡
1. Negative Rounding

We can specify an optional 2nd argument in Python's *round* function.

If we pass a negative value here, this will start rounding from the left of the decimal point; meaning we can round to the nearest 10, 100, and so on.
2. Reversing a String

There's an extremely easy way to reverse strings in Python using slicing.

Below we use [::-1]

This means start at the end of our string, and end up at position 0.
Read 22 tweets
Aug 5, 2021
9 Database basics you should probably know.

A Thread πŸ‘‡
1. What is a database?

This is essentially a container storing organised data electronically, usually controlled by something called a database management system (DBMS for short).

These can store more data (and are more secure) than a text file or spreadsheet.
2. What is a DBMS?

These are software packages which allow us to create, manipulate and manage our databases.

You've probably heard of some before.

They include:

-- MySQL
-- SQLite
-- PostgreSQL
Read 11 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(