mysql
基本命令
SHOW DATABASES;
SHOW TABLES;
USE DATABASE
CREATE DATABASE db_name
DROP DATABASE db_name
DESC table
SHOW CREATE TABLE table
DROP TABLE table
ALTER TABLE table ADD COLUMN col VARCHAR(10) NOT NULL
CHANGE COLUMN
DROP COLUMN
SELECT *
FROM table
WHERE condition
ORDER BY name DESC
LIMIT num OFFSET skip_numSELECT COUNT(*) num
FROM table
GROUP BY name;AVG(column)
SUM()
MAX()
MIN()
SELECT *
FROM table1, table2alias
SELECT
s.id sid
s.name
s.gender
c.id cid
c.name cname
FROM students s, classes c;SELECT
s.id
s.class_id
c.name class_name
FROM students s
INNER JOIN classes c
ON s.class_id = c.id;RIGHT OUTER JOIN 右表溢出
LEFT OUTER JOIN
FULL OUTER JOIN
INSERT
INSERT INTO table (col1, col2) VALUES (val1, val2), (val3, val4);UPDATE
UPDATE table SET col1=val1, col2=val2 WHERE condition;DELETE
DELETE FROM table WHERE conditionREPLACE INTO
INSERT IGNORE INTO
INSERT INTO …… ON DUPLIOCATE KEY UPDATE col1=val1, col2=val2;