0015.1 mysql
- 설치
brew install mysql
brew services start mysql
- 실행
mysql -u root -p
후 비밀번호 입력
- DCL
- 비밀번호 설정 참고
- mysql 셸에서
ALTER USER 'username'@'host' IDENTIFIED BY 'password'; FLUSH PRIVILEGES;
- 또는
SET PASSWORD FOR 'username'@'%' = 'password';
- 권한 부여
GRANT
- 권한 확인
SHOW GRANTS;
, SHOW GRANTS FOR 'username'@'localhost';
- DDL
CREATE TABLE
UPDATE
DROP
ALTER
PRIMARY KEY
AUTO_INCREMENT
NOT NULL
UNIQUE
DEFAULT <value>
CHECK(<condition>)
- DML
- mysql 샘플 데이터베이스
SELECT
SELECT * FROM tablename
SELECT columns, ... FROM tablename
SELECT DISTINCT exclude_column FROM tablename
AS
ORDER BY
WHERE
AND
OR
NOT
LIKE
BETWEEN _ AND _
LIMIT 1
LIMIT 10, 5
: pagination
- GROUP BY
CASE WHEN
ROW_COUNT()
- JOIN
INNER JOIN
LEFT JOIN
RIGHT JOIN
ROW_NUMBER()
INSERT
UPDATE
SET SQL_SAFE_UPDATES = 0
SET
WHERE
CASE WHEN THEN ELSE END
- Subquery
REGEXP
DELETE
WHERE
JOIN
USING
RETURNING
: Only on PostgreSQL, 삭제한 행을 반환
- Types
- DATETIME
- TIMESTAMP
- 0015.1.1 DATETIME과 TIMESTAMP의 차이
Troubleshooting