1) 데이터 정의 언어 (DDL: Data Definition Language)
- CREATE, ALTER, DROP 등의 명령어
2) 데이터 조작 언어 (DML: Data Manipulation Language)
- INSERT, UPDATE, DELETE, SELECT 등의 명령어
3) 데이터 제어 언어 (DCL: Data Control Language)
- GRANT, REVOKE, COMMIT, ROLLBACK 등의 명령어
mysql -u root -p
SHOW DATABASES;
CREATE DATABASE dbname;
CREATE DATABASE testdb;
USE testdb;
DROP DATABASE testdb;
use mysql;
SELECT host, user FROM user;
CREATE USER 'noma'@'localhost' identified by '1234';
CREATE USER 'noma'@'%' identified by '1234';
DROP USER 'username'@'localhost'
DROP USER 'username'@'%'
DROP USER 'noma'@'localhost'
SHOW GRANTS FOR 'noma'@'localhost';
GRANT ALL ON testdb.* to 'noma'@'localhost';
REVOKE ALL ON testdb.* from 'noma'@'localhost';
FLUSH PRIVILEGES;
CREATE DATABASE zerobase DEFAULT CHARACTER SET utf8mb4;
create table mytable
(
id int,
name varchar(16)
);
show tables;
desc mytable;
alter table mytable rename person;
alter table person add column agee double;
alter table person
modify column agee int;
- person 테이블의 agee 컬럼 이름을 age로 변경
alter table person
change column agee age int;
alter table person
drop column age;
drop table person;