> For the complete documentation index, see [llms.txt](https://simian114.gitbook.io/blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://simian114.gitbook.io/blog/undefined/sql/practice/table.md).

# TABLE 관리

### CREATE TABLE

데이터베이스 안에 새로운 테이블을 생성한다.

#### SYNTAX

```sql
CREATE TABLE table_name (
    column1 datatype,
    column2 datatype,
    column3 datatype,
   ....
);
```

* `column` 은 테이블의 열 이름을 지정해준다.
* `datatype` 은 해당 열의 데이터 타입을 지정해 줌
  * `varchar`, `integer`, `date`, `text`, `etc..`

### CREATE TABLE USING ANOTHER TABLE

> 이미 존재하는 다른 테이블을 이용해서도 새로운 테이블을 만들 수 있다.

#### SYNTAX

```sql
CREATE TABLE new_table_name AS
    SELECT column1, column2,...
    FROM existing_table_name
    WHERE ....;
```

### DROP TABLE

데이터베이스에 존재하는 테이블을 삭제하는데 사용된다.

#### SYNTAX

```sql
DROP TABLE table_name;
```

> > 주의! 삭제관련 명령은 경고문이 나오지 않는다. 따라서 중요 데이터베이스도 삭제할 수 있는 위험이 있음.

### TRUNCATE TABLE

이미 존재하는 테이블을 비우는데 사용된다.

#### SYNTAX

```sql
TRUNCATE TABLE table_name;
```

### ALTER TABLE

`ALTER TABLE` 는 존재하는 테이블의 `열`을 `추가, 삭제 수정` 한다. 또한 `열` 에 걸려있는 제한(`constraints`)을 추가하거나 삭제하기도 한다.

### ADD Columns

#### SYNTAX

```sql
ALTER TABLE table_name
ADD column_name datatype;
```

### DROP Columns

#### SYNTAX

```sql
ALTER TABLE table_name
DROP COLUMN column_name;
```

### MODIFY Columns

#### SYNTAX

```sql
ALTER TABLE table_name
ALTER COLUMN column_name datatype;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://simian114.gitbook.io/blog/undefined/sql/practice/table.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
