mysql数据库命令大全
时间: 2023-09-11 10:08:58 浏览: 39
以下是常用的 MySQL 数据库命令大全:
1. 连接到 MySQL 数据库:
```
mysql -u username -p
```
2. 显示所有数据库:
```
show databases;
```
3. 创建新数据库:
```
create database dbname;
```
4. 删除数据库:
```
drop database dbname;
```
5. 使用数据库:
```
use dbname;
```
6. 显示所有表格:
```
show tables;
```
7. 显示表格结构:
```
describe tablename;
```
8. 创建新表格:
```
create table tablename (column1 datatype, column2 datatype, column3 datatype);
```
9. 删除表格:
```
drop table tablename;
```
10. 插入数据:
```
insert into tablename (column1, column2, column3) values (value1, value2, value3);
```
11. 查询数据:
```
select * from tablename;
```
12. 更新数据:
```
update tablename set column1=value1, column2=value2 where condition;
```
13. 删除数据:
```
delete from tablename where condition;
```
14. 添加列:
```
alter table tablename add column datatype;
```
15. 修改列:
```
alter table tablename modify column datatype;
```
16. 删除列:
```
alter table tablename drop column;
```
17. 重命名表格:
```
rename table oldname to newname;
```
18. 导出数据:
```
mysqldump -u username -p dbname > filename.sql
```
19. 导入数据:
```
mysql -u username -p dbname < filename.sql
```
以上是常用的 MySQL 数据库命令大全,希望能帮助到你。
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)