当前位置:网站首页>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 .
边栏推荐
- Component、Container容器常用API详解:Frame、Panel、ScrollPane
- Understanding of cross domain and how to solve cross domain problems
- Arcpy 利用updatelayer函数改变图层的符号系统
- 实用的小工具指令
- Average two numbers
- C语言中的函数(详解)
- 24 magicaccessorimpl can access the debugging of all methods
- Grounding relay dd-1/60
- Layoutmanager layout manager: flowlayout, borderlayout, GridLayout, gridbaglayout, CardLayout, BoxLayout
- 树形dp
猜你喜欢
C实现贪吃蛇小游戏
How to solve the component conflicts caused by scrollbars in GridView
ORICO ORICO outdoor power experience, lightweight and portable, the most convenient office charging station
[problem record] 03 connect to MySQL database prompt: 1040 too many connections
Design and implementation of redis 7.0 multi part AOF
测试岗的中年危机该如何选择?是坚守还是另寻出路?且看下文
How to choose the middle-aged crisis of the testing post? Stick to it or find another way out? See below
Leakage detection relay jy82-2p
JSON Web Token----JWT和傳統session登錄認證對比
实用的小工具指令
随机推荐
Sleep quality today 78 points
C # symmetric encryption (AES encryption) ciphertext results generated each time, different ideas, code sharing
Understanding of cross domain and how to solve cross domain problems
Manually page the list (parameter list, current page, page size)
High performance parallel programming and optimization | lesson 02 homework at home
STM32 单片机ADC 电压计算
剑指 Offer II 038. 每日温度
1、 Relevant theories and tools of network security penetration testing
8. Factory method
How to implement lazy loading in El select (with search function)
JS execution mechanism
C实现贪吃蛇小游戏
Lightroom import picture gray / Black rectangular multi display
Grounding relay dd-1/60
7. Agency mode
Realize IIC data / instruction interaction with micro batg135
[Chongqing Guangdong education] electronic circuit homework question bank of RTVU secondary school
Leetcode question brushing record | 206_ Reverse linked list
Component、Container容器常用API详解:Frame、Panel、ScrollPane
Invalid revision: 3.18.1-g262b901-dirty