当前位置:网站首页>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;
边栏推荐
- 个人博克系统登录点击图形验证码的集成与实现
- 英文翻译阿拉伯语-批量英文翻译阿拉伯语工具免费
- Business visualization - let your flowchart "run" (4. Actual business scenario test)
- There is a 'single quotation mark' problem in the string when Oracle inserts data
- leetcode day4 部门工资最高的员工
- Question bank and answers of the latest national fire-fighting facility operators (intermediate fire-fighting facility operators) in 2022
- MySQL8 Status Variables: Internal Temporary Tables and Files
- 彻底理解位运算——与(&)、非(~)、或(|)、异或(^)
- [network] communication across regional networks learn how routing tables work
- 你知道雨的类型有几种?
猜你喜欢
英语文章翻译-英语文章翻译软件-免费批量翻译
Netcoreapi operation excel table
idea properties文件显示\u不显示中文的解决
Sprint for golden nine and silver ten, stay up at night for half a month, collect 1600 real interview questions from Android post of major manufacturers
Question bank and answers of the latest national fire-fighting facility operators (intermediate fire-fighting facility operators) in 2022
Rust Getting Started Guide (rustup, cargo)
Concurrent programming, do you really understand?
云计算笔记part.1——系统管理
NDK 系列(5):JNI 从入门到实践,爆肝万字详解!
Cell综述:人类微生物组研究中的单细胞方法
随机推荐
并发程序设计,你真的懂吗?
Overcome the "fear of looking at teeth", and we use technology to change the industry
个人博克系统登录点击图形验证码的集成与实现
开盘暴涨215%!国产信号链芯片企业芯海科技登陆科创板
MySQL8 tmp_ table_ Size and Max_ heap_ table_ size
In order to develop high-end photoresist, Jingrui Co., Ltd. invested 75million yuan to purchase SK Hynix ASML lithography machine
Amazon launched Amazon one palm payment system, and the contactless palm vein recognition market is expected to explode
leetcode day3 超过经理收入的员工
Cloud computing notes part.2 - Application Management
Test Development Notes
String中常用的API
NetCoreAPI操作Excel表格
华为入股南京芯视界,布局固态激光雷达芯片领域
博途1200/1500PLC上升沿下降沿指令编程应用技巧(bool数组)
The peak rate exceeds 2gbps! Qualcomm first passed 5g millimeter wave MIMO OTA test in China
文章翻译软件-批量免费翻译软件支持各大翻译接口
MIR专题征稿 | 常识知识与推理:表示、获取与应用 (10月31日截稿)
There are five certificates in the soft examination advanced examination, which is more worth taking?
Rust 入门指南(crate 管理)
利用STM32的HAL库驱动1.54寸 TFT屏(240*240 ST7789V)