一、数据库操作
*创建数据库:
CREATE DATABASE db_name;
*删除数据库:
DROP DATABASE db_name;
*使用数据库:
USE db-name;
——————————————————————
二、表操作
*创建表:
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
);
*删除表:
DROP TABLE table_name;
*修改表结构:
ALTER TABLE table_name ADD column_name datatype;
——————————————————————
三、数据操作
*插入数据:
INSERT INTO table_name(column1,column2,........) VALUES (value1,value2,........);
*查询数据:
SELECT column1,column2 FROM table_name WHERE condition;
*更新数据:
UPDATE table_name SET column1= value1 WHERE condition;
*删除数据:
DELETE FROM table_name WHERE condition;
四、数据查询
*条件查询:
SELECT * FROM table_name WHERE column_name = value;
*排序:
SELECT * FROM table_name ORDER BY column_name ASC|DESC;
分组
SELECT column_name, COUNT() FROM table_name GROUP BY column_name;
*连接查询:
SELECT a.column1, b.column2
FROM table_a a
JOIN table_b b ON a.common_column = b.common_column;