mysql> show databases;
- 현제 생성된 데이터 베이스 보기
+----------+
| Database |
+----------+
| mysql |
+----------+
1 row in set (0.00 sec)
mysql> create database test; - test 라는 데이터 베이스 생성
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+----------+
| Database |
+----------+
| mysql |
| test |
+----------+
2 rows in set (0.00 sec)
mysql> use test; - test 데이터 베이스를 사용함
Database changed
mysql> create table saram(id char(10), name char(20), age int);
- test 데이터 베이스에 saram 이라는 테이블 생성
Query OK, 0 rows affected (0.04 sec)
mysql> describe saram; - 테이블의 목록을 본다
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| id | char(10) | YES | | NULL | |
| name | char(20) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.02 sec)
mysql> desc saram; - 목록 보기의 다른 명령어
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| id | char(10) | YES | | NULL | |
| name | char(20) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.01 sec)
mysql> insert into saram(id, name, age) values('aaa','gildong', 32);
- 생성된 테이블에 정보를 넣는 구문
Query OK, 1 row affected (0.02 sec)
mysql> select * from saram; - 테이블의 내용 보기
+------+---------+------+
| id | name | age |
+------+---------+------+
| aaa | gildong | 32 |
+------+---------+------+
1 row in set (0.00 sec)
mysql> select name, age from saram; - 테이블의 내용중 원하는 부분만 보기
+---------+------+
| name | age |
+---------+------+
| gildong | 32 |
+---------+------+
1 row in set (0.01 sec)
mysql> insert into saram values('bbb','sunshin',400); - 데이터를 넣는 다른 유형
Query OK, 1 row affected (0.01 sec)
mysql> insert into saram values('ccc','ginea',20);
Query OK, 1 row affected (0.01 sec)
mysql> select * from saram;
+------+---------+------+
| id | name | age |
+------+---------+------+
| aaa | gildong | 32 |
| bbb | sunshin | 400 |
| ccc | ginea | 20 |
+------+---------+------+
3 rows in set (0.00 sec)
mysql> update saram set name='jinea' where id='ccc';
- 테이블 내 데이터 수정
* 주의할점 where id 를 넣지않으면 테이블 내에 모든 내용이 바뀐다
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from saram;
+------+---------+------+
| id | name | age |
+------+---------+------+
| aaa | gildong | 32 |
| bbb | sunshin | 400 |
| ccc | jinea | 20 |
+------+---------+------+
3 rows in set (0.01 sec)
mysql> alter table saram change age nai tinyint;
- 테이블의 목록 이름 및 변수타입을 바꿔주는 명령어
Query OK, 3 rows affected, 1 warning (0.10 sec)
Records: 3 Duplicates: 0 Warnings: 1
mysql> select * from saram;
+------+---------+------+
| id | name | nai | - 목록 이름이 바뀌었다
+------+---------+------+
| aaa | gildong | 32 |
| bbb | sunshin | 127 | - tinyint 의 값이 -128~127 이기 때문에
| ccc | jinea | 20 | 127 초과 값인 400이 127로 바뀐다
+------+---------+------+
3 rows in set (0.00 sec)
mysql> delete from saram where id='ccc';
- 데이터 삭제 여기서도 where id 를 같이 쓰지 않으면 모두 삭제된다
Query OK, 1 row affected (0.00 sec)
mysql> select * from saram;
+------+---------+------+
| id | name | nai |
+------+---------+------+
| aaa | gildong | 32 |
| bbb | sunshin | 127 |
+------+---------+------+
2 rows in set (0.00 sec)
mysql> drop table saram; - 테이블 삭제 명령
Query OK, 0 rows affected (0.01 sec)
mysql> show tables;
Empty set (0.02 sec)
mysql> show databases;
+----------+
| Database |
+----------+
| mysql |
| test |
+----------+
2 rows in set (0.02 sec)
mysql> drop database test; - 데이터베이스 삭제 명령
Query OK, 0 rows affected (0.01 sec)
mysql> show databases;
+----------+
| Database |
+----------+
| mysql |
+----------+
1 row in set (0.00 sec)
mysql>
mysql> set password = password('변경할 패스워드'); - 패스워드변경
게시글 목록
| 번호 | 제목 |
|---|---|
| 32341 | |
| 32339 | |
| 32326 | |
| 32325 | |
| 32322 | |
| 32319 | |
| 32318 | |
| 32316 | |
| 32315 | |
| 32313 | |
| 32312 | |
| 32311 | |
| 32310 | |
| 32304 | |
| 32303 | |
| 32300 | |
| 32293 | |
| 32292 | |
| 32291 | |
| 32285 | |
| 32284 | |
| 32275 | |
| 32271 | |
| 32268 | |
| 32265 | |
| 32261 | |
| 32258 | |
| 32257 | |
| 32255 | |
| 32254 | |
| 32253 | |
| 32251 | |
| 32250 | |
| 32249 | |
| 32247 | |
| 32246 | |
| 32245 | |
| 32244 | |
| 32243 | |
| 32242 | |
| 32241 | |
| 32240 | |
| 32239 | |
| 32238 | |
| 32237 | |
| 32236 | |
| 32232 | |
| 32229 | |
| 32228 | |
| 32227 | |
| 32217 | |
| 32215 | |
| 32214 | |
| 32213 | |
| 32211 | |
| 32207 | |
| 32196 | |
| 32193 | |
| 32192 | |
| 32190 | |
| 32188 | |
| 32186 | |
| 32184 | |
| 32173 | |
| 32172 | |
| 32171 | |
| 32167 | |
| 32165 | |
| 32163 | |
| 32162 | |
| 32158 | |
| 32157 | |
| 32155 | |
| 32151 | |
| 32149 | |
| 32135 | |
| 32132 | |
| 32127 | |
| 32125 | |
| 32122 | |
| 32120 | |
| 32119 | |
| 32117 | |
| 32116 | |
| 32115 | |
| 32114 | |
| 32112 | |
| 32111 | |
| 32109 | |
| 32107 | |
| 32104 | |
| 32103 | |
| 32102 | |
| 32101 | |
| 32094 | |
| 32089 | |
| 20404 | |
| 31036 | |
| 8279 | |
| 8268 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기