当前位置:网站首页>Basic MySQL operations
Basic MySQL operations
2022-07-03 04:01:00 【Pedestrian on the road】
MySQL Basic function
One . Basic operation
1. Access to database
Mysql -uroot -p Enter the database password after entering
2. Query the database
show databases;
3. Create database student
create database student;
4. Delete database
drop database Database name
5. Using a database student
use student;
6. Create table
create table aa(id int(10),name varchar(20),city varchar(20));
7. Write data
insert into aa(id,name,city) values(1,"wang","beijing");
8. Query table data
select * from aa; Query all the data
select id,name from aa; Inquire about id and name Field
select city from aa where name="wang"; Inquire about name by wang Of city
9. Modifying data
update aa set name="song" where id=1;
10. Delete data
delete from aa where id=1;
- Advanced operation
- order by usage
select *from aa order by id desc; according to id Sort from high to low
select id,name from aa order by 1; With id Sort
select id,name from aa order by 2; With name Sort
2.limit usage
Limit M,N
// Says from the first M+1 Data starts , Query down in sequence N Data
Limit M
// Indicates before query M Data
select * from aa limit 2,2; Query table 3,4 Data
select id,name from aa limit 1,3; Inquire about id name Of 234 Data
3.union select Usage of
select * from aa union select 1,2,3; Query three columns and display at the bottom of each column
When the columns of the table and the columns of the query are inconsistent , You're going to report a mistake , It will also expose the value of the field
4.union select combination information_schema database
MySQL5.0 There is a version called information_schema The database of , It stores all the information in the database , It's about MySQL Information about all other databases maintained by the server . Such as database name , Table of database , Data type and access right of table column . and 5.0 There is no .
show databases;
select schema_name from information_schema.schemata;
The execution result of two sentences is the same
use student;
show tables;
select table_name from information_schema.tables where table_schema='student';
Found the same .
边栏推荐
- Recursion: depth first search
- Web session management security issues
- [DRM] simple analysis of DRM bridge driver call process
- 【全民编程】《软件编程-讲课视频》【零基础入门到实战应用】
- 竞品分析撰写
- 2022 tea master (intermediate) examination questions and analysis and tea master (intermediate) practical examination video
- SAP UI5 应用开发教程之一百零五 - SAP UI5 Master-Detail 布局模式的联动效果实现明细介绍
- IPv6 foundation construction experiment
- 【刷题篇】接雨水(一维)
- 动态规划:最长公共子串和最长公共子序列
猜你喜欢
释放数据力量的Ceph-尚文网络xUP楠哥
[brush questions] most elements (super water king problem)
What is pytorch? Is pytorch a software?
2022-07-02: what is the output of the following go language code? A: Compilation error; B:Panic; C:NaN。 package main import “fmt“ func main() { var a =
"Final review" 16/32-bit microprocessor (8086) basic register
The 10th China Cloud Computing Conference · China Station: looking forward to the trend of science and technology in the next decade
Simple wechat applet development page Jump, data binding, obtaining user information, obtaining user location information
Nodejs Foundation: shallow chat URL and querystring module
在 .NET 6 项目中使用 Startup.cs
105. Detailed introduction of linkage effect realization of SAP ui5 master detail layout mode
随机推荐
Arduino application development - LCD display GIF dynamic diagram
Intercept string fixed length to array
105. SAP UI5 Master-Detail 布局模式的联动效果实现明细介绍
[learning notes] seckill - seckill project - (11) project summary
Ffmpeg download and installation tutorial and introduction
Social phobia of contemporary young people (III)
Causal AI, a new paradigm for industrial upgrading of the next generation of credible AI?
2022 P cylinder filling examination content and P cylinder filling practice examination video
Ffmpeg recording screen and screenshot
JS实现图片懒加载
没有sXid,suid&sgid将进入险境!-尚文网络xUP楠哥
【学习笔记】seckill-秒杀项目--(11)项目总结
Dynamic programming: Longest palindrome substring and subsequence
For instruction, uploading pictures and display effect optimization of simple wechat applet development
如何迈向IPv6之IPv6过渡技术-尚文网络奎哥
2022-07-02:以下go语言代码输出什么?A:编译错误;B:Panic;C:NaN。 package main import “fmt“ func main() { var a =
Is pytorch difficult to learn? How to learn pytorch well?
sigaction的使用
C语言HashTable/HashSet库汇总
Shardingsphere dynamic data source