# UPDATE / DELETE

### **UPDATE / SET**

특정 행의 데이터를 수정하고 싶으면 UPDATE 문법을 씁시다.

```sql
UPDATE 테이블명 
SET 컬럼1 = 값, 컬럼2 = 값
WHERE 조건식  
```

SET 뒤엔 컬럼마다 어떤 값으로 수정할 것인지 선택하면 됩니다.&#x20;

WHERE 뒤엔 어떤 행을 업데이트할 것인지 조건식을 넣어줍니다.

```sql
-- 사용 예시
UPDATE temp 
SET 상품명 = '오이', 가격 = 1000
WHERE id = 10 
;
```

값을 완전히 대체해버리는게 아니라 기존 값에 덧셈 곱셈 나눗셈도 할 수 있습니다.&#x20;

그래서 SET 뒤에 나오는 = 기호는

같다는 뜻이 아니라 "오른쪽 값을 왼쪽에 넣어주세요\~" 라는 뜻과 더 비슷합니다.&#x20;

```sql
UPDATE temp 
SET 상품명 = '오이', 가격 = 가격+200
WHERE id = 10 
;
```

### **DELETE FROM**

특정 row를 아예 삭제하고 싶으면 DELETE 사용합니다.

```sql
DELETE FROM 테이블명 WHERE 조건식 
```

이렇게 하면 조건식에 맞는 모든 행을 삭제해줍니다.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://leeans-dev-book.gitbook.io/docs/lecture/database/update-delete.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
