# 인덱스 관리

## 인덱스(Index)

이 문서에서는 인덱스(Index)의 역할과 관리 방법에 대해서 다룬다.

### 인덱스란

데이터베이스 객체 중 하나 테이블에 부여하여 검색 속도를 향상 시키는 역할을 수행한다.

![이름에 index 설정한 경우의 예](/files/-MgsaxXxt2wef2XD1jq3)

### 인덱스 생성

인덱스는 일반 컬럼이나 유니크 컬럼에 설정할 수 있다. 유니크(UNIQUE) 또는 기본키(PRIMARY KEY) 컬럼은 기본적으로 인덱스가 설정된다.

#### 일반 컬럼에 인덱스 설정

```sql
CREATE INDEX 이름 ON 테이블(컬럼)
```

#### 유니크 컬럼에 인덱스 설정

```sql
CREATE UNIQUE INDEX 이름 ON 테이블(컬럼)
```

### 인덱스 제거

```sql
DROP INDEX 이름;
```

### 인덱스 조회

```sql
SELECT * FROM ALL_IND_COLUMNS WHERE TABLE_NAME = "테이블명";
```

### 인덱스 리빌드

인덱스를 이용하다보면 잦은 데이터 변화로 인하여 인덱스의 불균형이 발생하는 경우가 있다. 이럴 경우 리빌드 명령을 이용하여 인덱스를 균형잡히게 바꿔야 한다.

![불균형 상태를 균형 상태로 바꾸는 예](/files/-MgscJJBvWbRRo8CGztU)

```sql
ALTER INDEX 이름 REBUILD;
```


---

# 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://docs.sysout.co.kr/database/oracle/structure-query-language/user-query/manage-index.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.
