当前位置:网站首页>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;
边栏推荐
- Test Development Notes
- App自动化测试是怎么实现H5测试的
- Force buckle 1331. Array serial number conversion
- 英文翻译意大利语-批量英文翻译意大利语工具免费
- Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)
- navicate修改数据库名的方式
- China's first chip stamp released: built-in 120um ultra-thin NFC chip
- Scrapy Spider源码分析
- App自动化测试是怎么实现H5测试的
- NetCoreAPI操作Excel表格
猜你喜欢

云计算笔记part.1——系统管理

How does app automated testing achieve H5 testing

OpenOCD如何通过stlink直接下载程序到stm32板子(已解决)

Codeignier framework implements restful API interface programming

英文翻译西班牙语-批量英文翻译西班牙工具免费

Rust 入门指南(crate 管理)

editor.md中markdown编辑器的实现

Rust Getting Started Guide (rustup, cargo)

彻底理解位运算——左移、右移

Question bank and answers of the latest national fire-fighting facility operators (intermediate fire-fighting facility operators) in 2022
随机推荐
利用STM32的HAL库驱动1.54寸 TFT屏(240*240 ST7789V)
Android-第十三节03xUtils-数据库框架(增删改查)详解
Leetcode Day5 delete duplicate email
leetcode day3 查找重复的电子邮箱
Redis notes
MySQL8 tmp_table_size和max_heap_table_size
NetCoreAPI操作Excel表格
Leetcode day3 employees who exceed the manager's income
认识中小型局域网WLAN
[网络]跨区域网络的通信学习路由表的工作原理
英文翻译意大利语-批量英文翻译意大利语工具免费
stc12c5a60s2功能说明(STC12C5A60S2默认触发)
Amazon launched Amazon one palm payment system, and the contactless palm vein recognition market is expected to explode
【NPP安装插件】
The opening price soared by 215%! Domestic signal chain chip enterprise Xinhai Technology landed on the scientific innovation board
Leetcode day4 the highest paid employee in the Department
Verification of chip power consumption performance: from dilemma to transcendence
Quickly install torch spark, torch geometric and other packages in moment pool cloud
云计算笔记part.2——应用管理
Nokia expands its 5g agreement with BT and will become its largest wireless access device supplier