美文网首页
Mysql操作——DML-2.更新操作

Mysql操作——DML-2.更新操作

作者: 乄Denve彡 | 来源:发表于2019-03-22 12:13 被阅读0次
    更新操作

    \color{red}{update 表名 set 列名1=列值1,列名2=列值2......where 列名=值;}

    • 把所有学生的分数改为90
    mysql> update students set score=90;
    
    • 把姓名为zs的学生分数改为60
    mysql> update students set score=60 where name='zs';
    
    • 把姓名为李四的年龄改为20,分数改为70
    mysql> update students set age=30,score=70 where name='ls';
    
    • 把wc的年龄在原来的基础上加1岁
    mysql> update students set age=age+1 where name='wc';
    
    • \color{red}{修改数据库密码方式1}
    mysql> update user set authentication_string=password('root') where user='root' and Host = 'localhost';
    mysql> flush privileges; # 刷新Mysql的系统权限相关表
    
    
    • \color{red}{修改数据库密码方式2}

    设置好环境标量后,在cmd终端输入命令修改密码

    C:\Users\Denve>mysqladmin -u root -p password root;
    

    相关文章

      网友评论

          本文标题:Mysql操作——DML-2.更新操作

          本文链接:https://www.haomeiwen.com/subject/ogxlvqtx.html