当前位置:网站首页>Simple use of MySQL database: add, delete, modify and query

Simple use of MySQL database: add, delete, modify and query

2022-07-06 06:46:00 Lu__ xiao

increase 、 Delete 、 Change 、 check

Mysql -u root -p   Connect to database

show databases;        view the database

create database xxx; establish xxx database

use xxx                        Use xxx database

create table result(id int(8),name varchar(20),city varchar(20),score int(5)); 

In the database student Create a table result

In the table resuit Insert 5 Data

insert into result(id,name,city,score) values(1,"wang","beijing",75);

insert into result(id,name,city,score) values(3,"li","shanghai",80);

insert into result(id,name,city,score) values(5,"chen","fuzhou",70);

insert into result(id,name,city,score) values(2,"zhou","xian",90);

insert into result(id,name,city,score) values(7,"han","guangzhou",65);

Be careful : If the data is character type (varchar), Must be wrapped in single or double quotation marks .

After successful insertion , You can use the following command to query result Everything in the table :

Select * from result;

In the table result Delete in id=3 The data of

delete from result where id=3;

modify id=5 The data of , Put it score Set to 60,

update result set score=60 where id=5;

select * from result; Query all fields in the table

select name,score from result;  Look up name and score Field

select score from result where name="chen";    Inquire about name by chen Student scores

原网站

版权声明
本文为[Lu__ xiao]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202132006117867.html