mysql基础语句
建库
Create database 名字
id是整数 不用加引号
插入insert into stu (id ,name);
values (2,名字);
删除行记录
Delete from stu; 从哪张表删除
Delete from stu where age =18: 删除表里年龄18的记录
修改 把表里的年龄修改为16
语法语句
update stu set age =16
把 李三的年龄改为16
Update stu set age = 16 where id =1 (条件不充分)
Update stu set age = 16 where name=‘李三’
查询这张表的所有记录
Select * from stu;#星号代表所有
语句一:select count(*) from T;
作用:查询T表中数据的行数。
语句二:select * from T;
作用:查询T表中所有的数据。
查询出所有年龄为18的学生的学号 名字
Select * from stu where age = 18
多表查询
两个表里
查询 所有表的name score
Select stu,name from stu,couse where stu ,id=course,id
找出表里得所有记录
Select*from stu ;
查出表里的记录所有数目
Select count(*) from stu
查出表里年龄最大的
Select Max(age) from stu
找出表里所有年龄最大的记录
1.select * from stu where age =(select max (age) from stu);
2.select id,name,age where age =(select max (age)form stu);
Hive数据库查询
Show :查看数据库,表,视图
Hive>Show database like ‘h*’; #;#like 模糊查询
Hive> use hive;
Hive>Show tables in hive like “u”;#查看数据库hive 中以u开头的所有表和视图
查找z 开头的所有名称文件
Hive > select * from stu where name like “z%”;