| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 29 | 30 | 31 |
- 포인터
- 배열
- 오블완
- 함수
- Pre-processing
- 티스토리챌린지
- string
- const
- pointer
- baekjoon
- OOP
- 파이썬
- pass by reference
- Object Oriented Programming
- assignment operator
- Class
- Deep Learning
- Data Science
- 백준
- raw data
- 문자열
- array
- 알고리즘
- C++
- Python
- predictive analysis
- programming
- function
- 반복문
- vscode
- 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 |