데이터베이스 관련 명령어
- mysql> show databases; //DB 목록보기 - mysql> use db명; //사용할 DB 선택 - mysql> show tables; //테이블 목록 보기 |
테이블 정의 명령어(create, alter, drop)
// 테이블 구조(필드) 변경하기
(1) 필드 추가 mysql> alter table customer add age int; mysql> desc customer; (2) 필드 삭제 mysql> alter table customer drop age; mysql> desc customer; (3) 필드 수정 mysql> alter table customer change phone tel int; mysql> desc customer; (4) 필드 타입 수정 mysql> alter table customer modify tel char(12); mysql> desc customer; (5) 테이블 이름 변경 mysql> alter table customer rename new_customer; mysql> show tables; |
//테이블 삭제 mysql> drop table new_customer; mysql> show tables; |
데이터 조작 명령어(select, insert, update, delete)
// 데이터 조회 mysql> select * from customer; |
// 데이터 삽입 mysql> insert into customer values('1','Kil-Dong','Hong','123-4567'); |
mysql> select * from customers;
mysql> select f_name, phone |
// 데이터 수정 mysql> update customer set phone = '111-1111' where id = '3';
mysql> select * |
// 데이터 삭제 mysql> delete from customer where f_name = 'bum';
mysql> select * |
// 데이터 조회 mysql> select * from customer order by f_name;
mysql> select * where f_name like 'M%'; |
제일 기본적인 것만 정리했음




덧글