当前位置:网站首页>Fundamentals of SQL database operation
Fundamentals of SQL database operation
2022-07-04 06:32:00 【supermeatboy223】
MySQL Basic operation
1. Connect to database
Enter the command :
mysql -u root -p
After that Enter password Enter the database password
2. Display all database names in the system
Enter the command : show databases;
Be careful : most SQL Command to ; End of character .
3. New database student
Enter the command :
create database student ;
Again using show databases; Look at the results .
4. Using a database student
command :
use student;
5. In the database student Create a table result
command : create table result (id int(8),name varchar(20),city varchar(20),score int(5));
6. In the table result Add data to
stay result Insert data
command :
insert into result(id,name,city,score) values(1,"wang","beijing",75);
Be careful When defining the form, you define the type for each data among id , score by int Integer type When adding data, increase the integer
name,city Defined characters char so When adding data increase "wang" "bengjing" Put in quotation marks .
Repeat adding data similar to the above command .
After successful insertion Use select * from result; see result Everything in the table .
7. In the table result Delete in 1 Data
for example , Delete name = "han" This data of .
delete from result where name = "han";
After deleting successfully see select * from result;.
8. Modify table result Data in the
for example , modify name = "zhou" The data of , Put it id Set to 4.
update result set id=4 where name ="zhou" ;
View results
9. Query table result Data in
for example :
select * from result ; // Query all fields in the table
select name,score,cty from result ; // In the query table name,score,city Field .
select score from result where name ="li"; // Inquire about name by li Of the students score.
The second part :MYSQL Advanced operation
1.order by Usage of
(1) take result The data in the table is ranked from high to low ;
select * from result order by score desc; // among ,desc Representation of descending order ,asc Expressing ascending order , If no parameter is added here, the default sorting is in ascending order .
边栏推荐
- How to help others effectively
- Learning multi-level structural information for small organ segmentation
- Learning multi-level structural information for small organ segmentation
- 17-18. Dependency scope and life cycle plug-ins
- 采用中微BATG135实现IIC数据/指令交互
- [problem record] 03 connect to MySQL database prompt: 1040 too many connections
- Appium foundation - appium installation (II)
- Design and implementation of redis 7.0 multi part AOF
- Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
- Functions in C language (detailed explanation)
猜你喜欢
uniapp 自定義環境變量
ABAP:OOALV实现增删改查功能
How to use multithreading to export excel under massive data? Source code attached!
JSON Web Token----JWT和传统session登录认证对比
[untitled]
C语言练习题(递归)
QT get random color value and set label background color code
746. Climb stairs with minimum cost
C language - Blue Bridge Cup - Snake filling
Sword finger offer II 038 Daily temperature
随机推荐
17-18. Dependency scope and life cycle plug-ins
MySQL installation and configuration
Practical gadget instructions
2022.7.3-----leetcode.556
Tree DP
Is the insurance annuity product worth buying? Is there a hole?
如何实现视频平台会员多账号登录
QT QTableWidget 表格列置顶需求的思路和代码
Tsinghua University product: penalty gradient norm improves generalization of deep learning model
Operator < <> > fool test case
uniapp 自定義環境變量
The solution of win11 taskbar right click without Task Manager - add win11 taskbar right click function
regular expression
How to realize multi account login of video platform members
InputStream/OutputStream(文件的输入输出)
[Android reverse] function interception (CPU cache mechanism | CPU cache mechanism causes function interception failure)
Cloud native - SSH article that must be read on the cloud (commonly used for remote login to ECS)
Overview of convolutional neural network structure optimization
[Chongqing Guangdong education] electronic circuit homework question bank of RTVU secondary school
2022.7.2-----leetcode. eight hundred and seventy-one