TABLE 생성
create table article( -- 테이블 명
title varchar(100), -- 최대 100바이트의 가변 길이 데이터 타입
body text -- 긴 문자열 데이터 타입. 최대 65535byte
);
TABLE 확인
show tables; -- 사용 중인 DB 안의 테이블을 리스팅

describe article; -- 'desc article;'와 같다.
-- 'article' 테이블 구조 확인

TABLE 삭제
drop table article; -- 'article' 테이블 삭제, 없으면 에러 발생
drop table if exists article; -- 'article' 테이블이 존재한다면 삭제
외래키가 있을 경우 참조 테이블을 먼저 삭제하거나 참조 테이블의 외래키를 삭제를 해야 가능하다.
TABLE 수정
-- 'article' 테이블에 datetime 타입의 'regDate' 컬럼을 끝에 추가
alter table article add column regDate datetime;
-- 'article' 테이블에 int 타입의 'id' 컬럼을 맨 앞에 추가
alter table article add column id int first;
-- 'article'테이블에 varchar 타입의 'writer' 컬럼을 'title' 뒤에 추가
alter table article add column writer varchar(100) not null after title;
-- 'article' 테이블에 'id' 컬럼에 기본키(PK) 속성 부여
alter table article add primary key(id);
-- 'article' 테이블에 기존에 있던 'id' 컬럼을 수정
alter table article modify column id int not null auto_increment;
-- 'article' 테이블에 'writer' 컬럼을 'nickname' 컬럼으로 변경
alter table article change `writer` `nickname` varchar(100) not null;
-- 'article' 테이블에 'hit' 컬럼을 삭제
alter table article drop column hit;