Database - SQL statements White Fun additions and deletions to change search

Connect mysql server and specify IP and port

mysql -uroot -proot -h127.0.0.1 -P3306 

View Gallery

show databases;

Into the library

use mysql;

View into the library

select database();

# Delete library - Avoid Mistakes

drop database mysql;
drop database if exists mydb1;

Create a library - and to specify the encoding (if not present)

create database if not exists mydb1 charset utf8;

View all current tables in the database

show tables;

Delete table (if present)

drop table if exists stu;

Create a table

create table stu(
id int primary key auto_increment
...,
...,
);

View table structure

desc stu;

Insert records into the table (data)

insert into stu values(null,'tom','男','1889-1-1',90);

View statement when construction of the table

show create table stu;

All information look-up table

select * from stu;

Modify the data in the table scores

update stu set score=score+10;

Delete all records in the table

delete from stu;
Published an original article · won praise 2 · views 60

Guess you like

Origin blog.csdn.net/weixin_46442173/article/details/104593462