mysql 常用语句
时间: 2023-07-24 22:17:23 浏览: 61
mysql常用语句
以下是 MySQL 常用的 SQL 语句:
1. 创建数据库
```
CREATE DATABASE database_name;
```
2. 删除数据库
```
DROP DATABASE database_name;
```
3. 创建表
```
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
);
```
4. 删除表
```
DROP TABLE table_name;
```
5. 插入数据
```
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
```
6. 更新数据
```
UPDATE table_name
SET column_name1 = value1, column_name2 = value2, ...
WHERE condition;
```
7. 删除数据
```
DELETE FROM table_name
WHERE condition;
```
8. 查询数据
```
SELECT column1, column2, ...
FROM table_name
WHERE condition;
```
9. 排序
```
SELECT column1, column2, ...
FROM table_name
ORDER BY column_name ASC|DESC;
```
10. 分组
```
SELECT column_name, COUNT(*)
FROM table_name
GROUP BY column_name;
```
11. 连接
```
SELECT column_name(s)
FROM table_name1
JOIN table_name2
ON table_name1.column_name = table_name2.column_name;
```
以上是 MySQL 常用的 SQL 语句,希望能对你有所帮助。
阅读全文