MySQL Query Manual - KOO-YS/toby-spring GitHub Wiki
์ค์ต๊ณผ ํจ๊ป ์ฌ์ฉ๋ ์ฟผ๋ฆฌ๋ฅผ ํ ๊ณณ์ ์ ๋ฆฌํด๋ณด์์ต๋๋ค.
1.1 ์ต์ด DB & User ํ ์ด๋ธ ์์ฑ
- ์ค์ต์ ์ํ DB ์์ฑ MySQL ์ฌ์ฉ
CREATE database toby DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
- users ํ ์ด๋ธ ์์ฑ
create table users (
id varchar(10) primary key,
name varchar(20) not null,
password varchar(10) not null
);
- ํ์ธ
full version
CREATE database toby DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> use toby
Database changed
mysql> create table users (
-> id varchar(10) primary key,
-> name varchar(20) not null,
-> password varchar(10) not null
-> );
Query OK, 0 rows affected (0.04 sec)
mysql> show tables;
+----------------+
| Tables_in_toby |
+----------------+
| users |
+----------------+
1 row in set (0.01 sec)
mysql>
5.1 Users ํ๋{level, login, recommend} ์ถ๊ฐ
- ์ฌ์ฉ์ ๋ ๋ฒจ ๊ด๋ฆฌ๋ฅผ ์ํ ์ปฌ๋ผ ์ถ๊ฐ
ALTER TABLE users
ADD COLUMN level tinyint NOT NULL DEFAULT 1,
ADD COLUMN login int NOT NULL DEFAULT 0,
ADD COLUMN recommend int NOT NULL DEFAULT 0;
5.4 Users ํ๋{email} ์ถ๊ฐ
- ๋ ๋ฒจ ์ ๊ทธ๋ ์ด๋ ์ ์ฌ์ฉ์์๊ฒ ์๋ด ๋ฉ์ผ ๋ฐ์กํ๊ธฐ ์ํ ์ปฌ๋ผ ์ถ๊ฐ
ALTER TABLE users
ADD COLUMN email varchar(50);