# MySQL Table

## SQL

Structured(구조화되어있다.) Query(데이터베이스에 질의한다.) Language의 약자이다.

* 압도적인 데이터베이스 시스템이 SQL로 작동되고 있다.

## 테이블 구조

![](http://cfile22.uf.tistory.com/original/17385D474D71A69C269849)

## 실습하기

### 테이블 생성하기

![](http://www.sqltutorial.org/wp-content/uploads/2016/04/SQL-Cheat-Sheet-2.png)

[데이터 타입 보기](https://www.techonthenet.com/mysql/datatypes.php)

```
mysql> CREATE TABLE topic(
    -> id INT(11) NOT NULL AUTO_INCREMENT,
    -> title VARCHAR(100) NOT NULL,
    -> description TEXT NULL,
    -> created_at DATETIME NOT NULL,
    -> author VARCHAR(30) NULL,
    -> profile VARCHAR(100) NULL,
    -> PRIMARY KEY(id));
Query OK, 0 rows affected (0.11 sec)
```

* NOT NULL : 공백은 허용하지 않는다.
* AUTO\_INCREMENT : 자동으로 한개씩 증가한다.
* PRIMARY KEY : 중복이 되지 않는 값, 식별자

### 테이블 보기

```
mysql> SHOW TABLES;
+-------------------------+
| Tables_in_opentutorials |
+-------------------------+
| topic                   |
+-------------------------+
1 row in set (0.01 sec)
```

### 테이블 구조 보기

```
mysql> DESC topic;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| id          | int(11)      | NO   | PRI | NULL    | auto_increment |
| title       | varchar(100) | NO   |     | NULL    |                |
| description | text         | YES  |     | NULL    |                |
| created_at  | datetime     | NO   |     | NULL    |                |
| author      | varchar(30)  | YES  |     | NULL    |                |
| profile     | varchar(100) | YES  |     | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+
6 rows in set (0.01 sec)
```


---

# 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://dahye-jeong.gitbook.io/database/mysql/2019-03-16-table.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.
