三十四 数据库
1、查看数据库命令
2、使用某个数据库
3、查看当前在哪个库
4、查看当前数据库中有哪些表
5、查询表中数据
6、建库:create database testbase;
7、建表:create table user(id int not null);
创建表,名字为user_wangjing,字段为 id,date1,date2等
新建表名,括号里意思是int 11位,不能为空
8、插入数据:insert into user values(1);
9、查看表的信息:
10、删除表
11、删除库:drop database testbase;
12、新建用户:
create user 'student11'@'%' identified by "gloryroad";
FLUSH PRIVILEGES;
%表示所有IP都可登录,'student11'@'10.60.89.%'表示只有这个字段的IP可以登录
13、修改密码:
UPDATE USER SET PASSWORD=PASSWORD('12345622xw1') WHERE USER='gg1';
FLUSH PRIVILEGES;
14、创建用户和修改用户的权限
grant all privileges on test.user to student@"%" identified by "gloryroad" ; #让用户拥有操作任意数据库的权限
flush privileges;
15、建表,插入值
ENGINE=InnoDB存储数据库采用innoDB引擎,如果你想使用外键,事务等功能,就需要innodb引擎
16、查看表的字段和属性: show columns from book_wangjing;
17、查看索引:SHOW INDEX FROM book_wangjing;
18、查看2条数据,从头开始前两条不看,打印接着后面的
19、查看2条之后的3条
20、查询表数据 and or:
21、给表中的字段起一个别名
22、表中字段的排序
select * from book where book_author like '%老师';
计算表中数据条数:
计算平均值: