mysql常用语法

 

1、新建用户a,设置密码为123456

create user 'a'@'%' identified by '123456';

 

2、删除用户a

drop user a;

 

3、新建数据库d

create database d;

 

4、新建表b

create table b(列名 类型,列名 类型)engine=innoDB default charset=utf8;

 

5、查看b表内容

select * from d.b;

 

6、删除b表的id为10的这一行数据

delete from d.b where id=10;

 

7、修改b表内容将id为10的这一行A列信息改成no

update d.b set A='no' where id=10;

 

8、表中新增数据

insert  into d.bset A列=no;(只添加一条数据时)

insert into d.bvalue(a,b,c);(()中依次填写所有列的值)

 

9、删除表b

drop table b;

delete from b;(只清除数据,不删除表结构等)

 

10、将用户名a改成c

rename user 'a'@'%' to 'c'@'%';

 

11、修改用户a的密码为654321

set password for 'a'@'%' =password('654321');

 

12、修改当前用户自己的密码为654321

set password =password('654321')

 

13、查询分组

group by

 

14、排序(默认是升序,降序的话加上desc)

order by

 

15、去重

distinct

 

16、统计数量

count(0)

或 count(*)

 

17、限定查询显示行数

limit n 

 

posted @ 2022-06-27 18:01  opscool  阅读(42)  评论(0)    收藏  举报