当前位置:网站首页>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 .


边栏推荐
- [Chongqing Guangdong education] electronic circuit homework question bank of RTVU secondary school
- How to realize multi account login of video platform members
- Displaying currency in Indian numbering format
- Sword finger offer II 038 Daily temperature
- Common JS tool Libraries
- Leetcode question brushing record | 206_ Reverse linked list
- QT get random color value and set label background color code
- 报错cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头。
- Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
- Software keywords and process information intercepted by Golden Shield video player
猜你喜欢

Uninstall Google drive hard drive - you must exit the program to uninstall

【MySQL】数据库视图的介绍、作用、创建、查看、删除和修改(附练习题)

Tf/pytorch/cafe-cv/nlp/ audio - practical demonstration of full ecosystem CPU deployment - Intel openvino tool suite course summary (Part 2)

AWT common components, FileDialog file selection box

SQL injection SQL lab 11~22

ABAP:OOALV实现增删改查功能

24 magicaccessorimpl can access the debugging of all methods

Appium foundation - appium installation (II)

JSON web token -- comparison between JWT and traditional session login authentication

Sword finger offer II 038 Daily temperature
随机推荐
Operator < <> > fool test case
Appium基础 — APPium安装(二)
Another company raised the price of SAIC Roewe new energy products from March 1
Cloud native - SSH article that must be read on the cloud (commonly used for remote login to ECS)
P26-P34 third_ template
SQL join, left join, right join usage
手动对list进行分页(参数list ,当前页,页面大小)
Compound nonlinear feedback control (2)
regular expression
C语言练习题(递归)
How to realize multi account login of video platform members
Arcpy 利用updatelayer函数改变图层的符号系统
[untitled]
70000 words of detailed explanation of the whole process of pad openvino [CPU] - from environment configuration to model deployment
InputStream/OutputStream(文件的输入输出)
Displaying currency in Indian numbering format
uniapp 自定義環境變量
Nexus 6p从8.0降级6.0+root
Fast power (template)
Variables d'environnement personnalisées uniapp


