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