找回密码
 立即注册

推荐阅读

  • 便民服务
  • 关注我们
  • 社区新手
12.16课程
insert into 表名 values(内容)
insert into 表名 (类型)values(数据1),(数据2):一次性插入多个数据

select * from   :*代表匹配所有的内容字段



select  特定字段的值1,值2 from:查询特定字段的值



select  * from 表名 where 值="数据" 查询对应的值的行数据
select  特定的值   from 表名 where 值="数据" :查询单个数据

查询为空:null,不是一个具体的属性值,不能用等号大于,小于进行查询,查询空用is null,不为空为 is not null


>  <,>=(大于等于),<=(小于等于),!=(不等于)查询比较某个数据的字段,
查询某个字段之间的内容 : >=  and  <=        ,between  数值1  and 数值2

or   或  查询区间的值
in 属于这个指定值的数据
not in 不属于指定值的数据
select * from  表名 where 值 like  "%值%":模糊匹配  

limit 查询指定行数
order   by   值  asc 从小到大排序(升序)(依据某个指定的字段及进行排序)
order  by   值   desc : 由大到小进行排序(降序)

group by  值  :分组查询使用 ,后面不能接条件where语句,但是可以使用having条件语句,前面可以接where
select count(*)  from 表名 group by 值:显示组里面有多少人
select * from 表名 group by 值 having  查询条件:

group by 一般接聚合函数使用,mysql 当中的方法
select max(值):求最大的值
select min(值):求最小的值
select  count(*)统计表的行数
select  avg(值):平均值
select  sum(值):求和
select  distinct(值):去重


修改表数据
update :修改
update 表名 set  查询条件:修改所有的数据
update 表名 set 值 where    :修改指定表数据
update 表名 set 值 where 条件1 or 条件2:修改指定字段
update 表名 set 字段1,字段2 where :修改两个字段
删除:delete from where,接条件删除指定的值,不接where 直接删除表数据
truncate  清空表数据


create table  新表名  like 原表名:复制一个相同类似的表结构,没有复制表的数据
insert into 新表 名(值)select  值 from 原表;备份一个表的所有数据

mysqldump  -u root -p 有数据的数据库>/有数据库数据库.sql :备份有数据的数据库到Linux系统
mysql  -u root -p sql中空的数据库:还原到sql




select user ,host from user:查看用户权限


insert into user(host,user,password)values("localhost","zhou",password("123456")):新增用户
flush privileges:刷新


在root用户下修改相应的用户权限,有时候修改完成后信息没有同步,所以需要进行刷新同步


grant all privileges on *.*to wuhan@localhost identified by "123456";:创建的同时给与所有的权限
select user ():查询当前正在使用数据库的人
select version()查询当前数据库使用的版本
select database(); 查询使用数据库:




分享至 : QQ空间
收藏

0 个回复

您需要登录后才可以回帖 登录 | 立即注册