| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
- baekjoon
- Python
- 파이썬
- C++
- 반복문
- Pre-processing
- 함수
- 오블완
- Deep Learning
- 배열
- Class
- programming
- 티스토리챌린지
- 포인터
- Object Oriented Programming
- raw data
- function
- assignment operator
- pointer
- string
- 문자열
- predictive analysis
- 알고리즘
- 백준
- const
- array
- Data Science
- pass by reference
- vscode
- OOP
- Today
- Total
Channi Studies
[MySQL] Day 4. AUTOCOMMIT, COMMIT, ROLLBACK 본문
Today, I learned about AUTOCOMMIT, COMMIT, and ROLLBACK keywords in MySQL.
AUTOCOMMIT is a mode; by default, AUTOCOMMIT is set to ON.
When AUTOCOMMIT is on (by default), every change you make is immediately nad permanently saved.
It means that you can't roll back if you made an error because each statement is automatically committed.
We can turn it off by using following statement:
SET AUTOCOMMIT = OFF;
Now, we can create a kind of a savepoint of your database.
COMMIT;
Simple as that.
Now, take a look at my database.

Yesterday, Eugene Krabs moved his job so I wanted to remove his data.
But, I forgot to include WHERE keyword after DELETE FROM keyword!!!
--delete every data from table employees
DELETE FROM employees;

Well, luckily I saved our table yesterday before I got off the work!
I want to roll back to the savepoint from yesterday by using:
ROLLBACK;
SELECT * from employees;

Our data was beautifully restored!! 🎉
'SQL' 카테고리의 다른 글
| [MySQL] Day 6. UNIQUE & Not Null Constraint (0) | 2025.04.01 |
|---|---|
| [MySQL] Day 5. CURRENT_DATE() & CURRENT_TIME() (0) | 2025.03.28 |
| [MySQL] Day 3. Update and Delete (0) | 2025.03.25 |
| [SQL] Day 2: INSERT INTO & SELECT WHERE (0) | 2025.03.15 |
| [SQL] Day 1: Database and Table (0) | 2025.03.14 |