MySQL--Common SQL commands

Show database
show databases;
Select database
use 数据库名
Show all tables in the library
show tables;
或者 show tables from 数据库名;
Show current database
select database();
Create table
create table stuinfo(
id int,
name varchar(20)
);
Add a primary key to the table
alter table 表名 add primary key (字段名);
Show table structure
desc 表名;
View table data
select * from 表名;
Insert data
insert into stuinfo(id,name) values(1,"john");
delete data
delete from stuinfo where id = 1;
change the data
update stuinfo set name="lilei" where id =1;

Guess you like

Origin blog.csdn.net/huangge1199/article/details/106970912