MySQL--常见SQL命令

显示数据库
show databases;
选择数据库
use 数据库名
显示库中所有表
show tables;
或者 show tables from 数据库名;
显示当前数据库
select database();
创建表
create table stuinfo(
id int,
name varchar(20)
);
给表添加主键
alter table 表名 add primary key (字段名);
显示表结构
desc 表名;
查看表数据
select * from 表名;
插入数据
insert into stuinfo(id,name) values(1,"john");
删除数据
delete from stuinfo where id = 1;
修改数据
update stuinfo set name="lilei" where id =1;

猜你喜欢

转载自blog.csdn.net/huangge1199/article/details/106970912