当前位置:网站首页>MySQL命令语句(个人总结)
MySQL命令语句(个人总结)
2022-07-28 17:59:00 【山河不见老】
目录
1 增加语句
1.1 向列表增加信息
insert into table_name(list_name,list_name......) values('values1','values2'.......),('values1','values2'........);
1.2 向表中增加列
增加列的操作类似下面这行代码,其中table_name是你要修改的表名,last_name是你想添加的列名,varchar(10)可以改为你想要的数据类型及取值范围。
alter table table_name add last_name varchar(10);
2 删除语句
2.1 删除指定的列
alter table table_name drop last_name;
2.2 删除指定信息
(删除一条或多条记录)
2.2.1 删除整个列表
delete from table_name;
2.2.2删除某条记录
delete from table_name where list_name='values';
2.3 清空表中数据
delete from table_name;
truncate table table_name;
3 修改信息
3.1 修改数据库编码
下面代码中的database_name是你要设置的数据库名称,gb2312可以替换为你自己想用的编码格式
alter database database_name character set gb2312;
3.2 修改某表的列的取值类型或范围
修改方法同上面几个例子
alter table table_name modify list_name varchar(10);
3.3 修改表名
now_name现在的表名
new_name修改后的表名
rename table now_name to new_name;
3.4 修改表的字符集编码格式为utf-8
alter table table_name character set utf-8;
3.5 修改列名
alter table table_name change column name list_name varchar(100);
3.6 修改记录
第一行的代码只是单纯的修改数据
第二行可以对数据在原有基础上进行加减
update table_name set list_name=values,list_name=values where list_name=values;
update table_name set list_name=value+1000 where list_name=value;
4 导出导入数据库
==进入cmd ==
4.1 导出数据库(sql脚本)
mysqldump -u 用户名 -p 数据库名 > 导出的文件名
mysqldump -u root -p db_name > test_db.sql
4.2 mysql导出数据库一个表
mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名
mysqldump -u wcnc -p test_db users> test_users.sql (结尾没有分号)
4.3 mysql导入数据库
source 文件目录/名称.sql
5 查询信息
5.1 查询表结构
desc table_name;
边栏推荐
- Investment of 3.545 billion yuan! Gree Group participates in Xiaomi industry fund
- MIR专题征稿 | 常识知识与推理:表示、获取与应用 (10月31日截稿)
- 你知道雨的类型有几种?
- Leetcode Day5 delete duplicate email
- editor.md中markdown编辑器的实现
- MySQL performance testing tool sysbench learning
- 英文翻译西班牙语-批量英文翻译西班牙工具免费
- English article translation - English article translation software - free batch translation
- Pagoda panel construction novel CMS management system source code measurement - thinkphp6.0
- Thoroughly understand bit operations -- and (&), not (~), or (|), XOR (^)
猜你喜欢

There is a 'single quotation mark' problem in the string when Oracle inserts data

High beam software has obtained Alibaba cloud product ecological integration certification, and is working with Alibaba cloud to build new cooperation

English article translation - English article translation software - free batch translation

Rust 入门指南(crate 管理)

What parameters should be passed in calling integer or character array functions

克服“看牙恐惧”,我们用技术改变行业

Oracle insert数据时字符串中有‘单引号问题

source insight项目导入和使用教程

Rust Getting Started Guide (modules and engineering structures)

leetcode day1 分数排名
随机推荐
Saltstack system initialization
navicate修改数据库名的方式
What parameters should be passed in calling integer or character array functions
Servlet学习笔记
彻底理解位运算——左移、右移
source insight项目导入和使用教程
idea properties文件显示\u不显示中文的解决
leetcode day4 部门工资最高的员工
[network] communication across regional networks learn how routing tables work
业务可视化-让你的流程图“Run“起来(4.实际业务场景测试)
博途1200/1500PLC上升沿下降沿指令编程应用技巧(bool数组)
并发程序设计,你真的懂吗?
助力面板行业创新,FPGA将成屏厂TCON最佳选择?
美国将提供250亿美元补贴,鼓励英特尔等芯片制造商迁回产线
This customized keyboard turns me on~
彻底理解位运算——与(&)、非(~)、或(|)、异或(^)
Leetcode day3 find duplicate email addresses
stc12c5a60s2功能说明(STC12C5A60S2默认触发)
redis 主从架构(sizeof函数怎么计算)
Integration and implementation of login click graphic verification code in personal blog system