副问题[/!--empirenews.page--]
【大咖·来了 第7期】10月24日晚8点寓目《智能导购对话呆板人实践》
本日先容的是关天Mysql数据库一些操纵的基本呼吁
用户与权限
建设用户
- mysql>create user test identified by 'BaC321@#';
修改暗码
5.5版本及早年的呼吁
- mysql>set password for test=passowrd('!1A@2#3');
5.6及以上呼吁
- mysql>update mysql.user set authentication_string=password('A1b2c3#!@') where user='test';
建设用户并授权
- mysql>grant select,insert,update on student.* to test@localhost identified by 'A1b2c3#!@';
查察授权
- mysql> show grants for test@localhost;
![MySQL数据库基本操纵呼吁](http://img26.aspzz.cn/uploads/allimg/c191021/15GA9D409110-12M5.png)
移除权限
- mysql> revoke insert,update on student.* from test@localhost;
建库与表
建设库
- mysql> create database student;
- mysql> show databases;
![MySQL数据库基本操纵呼吁](http://img26.aspzz.cn/uploads/allimg/c191021/15GA9D4350P-25596.png)
建设表
- mysql> use student;
- mysql> create table T1 (name varchar(10) not null,sex varchar(10) not null);
通过现有的表建设新表
- mysql> create table T2 as select * from T1;
插入数据
- mysql> insert into T1 values('zhang','man');
- Query OK, 1 row affected (0.03 sec)
- mysql> insert into T1 values('li','man');
- Query OK, 1 row affected (0.03 sec)
- mysql> insert into T1 values('wang','man');
- Query OK, 1 row affected (0.02 sec)
- mysql> insert into T1 values('zhao','women');
- Query OK, 1 row affected (0.05 sec)
- #必要留意的是假如列高出两列,就必要指定列字段名如下
- mysql> insert into T1(name,sex) values('gege','man');
查询数据
查询数据
- mysql> select user,host from mysql.user;
- #查察用户
- mysql> select * from T1 where name like '%an%';
- mysql> select * from T1 where age like '2%';
匹配查询
![MySQL数据库基本操纵呼吁](http://img26.aspzz.cn/uploads/allimg/c191021/15GA9D45H20-3I30.png)
- mysql> select * from T1 order by name,age;
查询排序
![MySQL数据库基本操纵呼吁](http://img26.aspzz.cn/uploads/allimg/c191021/15GA9D4S120-412V.png)
- mysql> select count(*) as toaolcount from T1;
- mysql> select sum(age) as sumvalue from T1;
- mysql> select avg(age) as avgvalue from T1;
- mysql> select max(age) from T1;
查询值
![MySQL数据库基本操纵呼吁](http://img26.aspzz.cn/uploads/allimg/c191021/15GA9D503250-5W43.png)
- mysql> select score from T1 where score <91;
- mysql> select score from T1 where score >=91;
- mysql> select * from T1 where score in (96,100);
(编辑:河北网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|