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('변경할 패스워드'); - 패스워드변경
게시판 목록
팁게시판
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5302 | 12년 전 | 1585 | ||
| 5301 |
냐옹이사범
|
12년 전 | 2294 | |
| 5300 | 12년 전 | 6510 | ||
| 5299 | 12년 전 | 5190 | ||
| 5298 | 12년 전 | 2990 | ||
| 5297 |
프로프리랜서
|
12년 전 | 2520 | |
| 5296 |
프로프리랜서
|
12년 전 | 1875 | |
| 5295 |
프로프리랜서
|
12년 전 | 2345 | |
| 5294 |
프로프리랜서
|
12년 전 | 1844 | |
| 5293 |
프로프리랜서
|
12년 전 | 1624 | |
| 5292 |
프로프리랜서
|
12년 전 | 5516 | |
| 5291 |
프로프리랜서
|
12년 전 | 2586 | |
| 5290 |
프로프리랜서
|
12년 전 | 3050 | |
| 5289 |
프로프리랜서
|
12년 전 | 1731 | |
| 5288 |
프로프리랜서
|
12년 전 | 1436 | |
| 5287 | 12년 전 | 2735 | ||
| 5286 |
오늘도망했다
|
12년 전 | 2332 | |
| 5285 |
오늘도망했다
|
12년 전 | 1668 | |
| 5284 |
오늘도망했다
|
12년 전 | 6631 | |
| 5283 |
오늘도망했다
|
12년 전 | 2492 | |
| 5282 | 12년 전 | 3631 | ||
| 5281 |
jinmuk
|
12년 전 | 1441 | |
| 5280 |
jinmuk
|
12년 전 | 4211 | |
| 5279 |
jinmuk
|
12년 전 | 5544 | |
| 5278 |
jinmuk
|
12년 전 | 2247 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기