#멋쟁이사자처럼 #부트캠프 #백엔드 #JAVA

Creating User and Database

CREATE USER 'like'@'%' IDENTIFIED BY 'lion'; -- For external access
CREATE USER 'like'@'localhost' IDENTIFIED BY 'lion'; -- For local access

CREATE DATABASE hr;

GRANT ALL PRIVILEGES ON hr.* to 'like'@'%';
GRANT ALL PRIVILEGES ON hr.* to 'like'@'localhost';

FLUSH PRIVILEGES;

DROP

Dropping Database

DROP DATABASE scott;
DROP DATABASE hr;

Dropping Users

DROP USER 'like'@'%';
DROP USER 'like'@'localhost';

Describing A Table

DESC emp;

List Tables

SHOW TABLES;

DISTINCT

SELECT DISTINCT deptno FROM emp;
SELECT deptno, ename, sal, comm
  FROM emp
 ORDER BY
       deptno DESC,
       sal DESC,
       ename;