2、mysql 授予权限grant to ,召回权限revoke from
create user 'marvin'@'%' indentified by 'password';
grant all privileges on database_name.* to 'marvin'@'%';
revoke insert,delete,update on database_name from 'marvin'@'%';
create database demo default charset utf8;
3、数据库
create database database_name;
use database_name;
4、数据表:
create table table_name(
字段1 类型(长度),
字段2 类型(长度)
)
desc table_name;
drop table table_name ;
5、查插删改基本操作:
select * from table where a=b;
insert into table (col1,col2,col3) values(val1,val2,val3);
insert into table values(val1,val2,val3);
delete * from table where cola=vala;
update table set colb=val5 where cola=vala;
6、约束
7、设计范式
8、查询语句:
select * from table where year(birthday) = year(now());
select * from students where name not like "王%";
select * from students order by age DESC,sno;
select max(age) as '最大',min(age) as '最小' from studens;
select class from studens where sex='男' group by class having count(*)>1;
select * from person left join card on persson.cardID=card.id;
select tname as name,tsex as sex from teacher union select sname as name,ssex as sex from students ;
select * from students order by age limit 0,2 ;
select * from students order by age limit 10,5;
select * from students order by age limit 5 offset 5;
select * from score where classno='2-105' and degree>any(select degree from score where classno='3-105') order by degree desc;
select distinct classno from students;
select sname from students where season in (select season_name in season);
select avg(score) from score where classno='2-105';
select 'x' from students where exists (select sno from lesons where teacher='张老师');
explain select * from students where sno='10003';
explain select * from students where sname like '张%';
explain select * from students where sname like '%鹏';
9、mysql存储数据量最大的数据格式LONGBLOB LONGTEXT,具体多少根据服务器和mysql版本不同。
10、索引index:
create index idx_index_name on table_name(cloum_name);
drop index idx_index_name on table_name;
11、视图view :
create view vw_stu_class as select cno,sname,sno from students,class where students.sno=class.sno;
select * from vw_stu_class ;