当前位置:网站首页>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 .
边栏推荐
- 中移物联网OneOS与OneNET入选《2021年物联网示范项目名单》
- Role of JS No
- [DRM] simple analysis of DRM bridge driver call process
- Practical operation of vim
- Mutex and rwmutex in golang
- Makefile demo
- Reflection and planning of a sophomore majoring in electronic information engineering
- "Designer universe" argument: Data Optimization in the design field is finally reflected in cost, safety and health | chinabrand.com org
- vim 的实用操作
- 8.8.2-PointersOnC-20220214
猜你喜欢
![[brush questions] connected with rainwater (one dimension)](/img/21/318fcb444b17be887562f4a9c1fac2.png)
[brush questions] connected with rainwater (one dimension)

CVPR 2022 | Dalian Institute of technology proposes a self calibration lighting framework for low light level image enhancement of real scenes

学会pytorch能干什么?

『期末复习』16/32位微处理器(8086)基本寄存器

Message queue addition failure

JMeter starts from zero (III) -- simple use of regular expressions

CVPR 2022 | Dalian Technology propose un cadre d'éclairage auto - étalonné pour l'amélioration de l'image de faible luminosité de la scène réelle

Mila、渥太华大学 | 用SE(3)不变去噪距离匹配进行分子几何预训练

毕设-基于SSM宠物领养中心

CEPH Shangwen network xUP Nange that releases the power of data
随机推荐
[mathematical logic] propositional logic (equivalent calculus | idempotent law | exchange law | combination law | distribution law | De Morgan law | absorption rate | zero law | identity | exclusion l
Dynamic programming: longest common substring and longest common subsequence
Appium automated testing framework
Web会话管理安全问题
How to download pytorch? Where can I download pytorch?
js实现在可视区内,文字图片动画效果
Filter
300+ documents! This article explains the latest progress of multimodal learning based on transformer
Ffmpeg recording screen and screenshot
【全民编程】《软件编程-讲课视频》【零基础入门到实战应用】
JMeter starts from zero (III) -- simple use of regular expressions
[mathematical logic] predicate logic (first-order predicate logic formula | example)
C语言HashTable/HashSet库汇总
[mathematical logic] propositional logic (judgment of the correctness of propositional logic reasoning | formal structure is eternal truth - equivalent calculus | deduction from premise - logical reas
105. SAP UI5 Master-Detail 布局模式的联动效果实现明细介绍
2022 polymerization process examination questions and polymerization process examination skills
[Yu Yue education] reference materials of political communication science of Communication University of China
【学习笔记】seckill-秒杀项目--(11)项目总结
Recursion: depth first search
Mila, University of Ottawa | molecular geometry pre training with Se (3) invariant denoising distance matching