CREATEdatabase b;
use b;
CREATETABLE Y(
NAMECHAR(3) ,
IDINT ,
XB CHAR(1),
cj int
);
desc Y;
insertinto Y values('赵三',1,'男',80);
insertinto Y (name,id,cj) values('李四',2,50);
insertinto Y(name,id,cj) values('王五',3,68);
insertinto Y setNAME = '赵六' , id = 4;
insertinto Y values('张三',7,'男',70);
insertinto Y values('张三',9,'男',40);
insertinto Y values('张三',65,'男',80);
select * from Y;
insertinto Y values('李华',5,'女',87);
select * from Y;
update Y set xb = '男'wherename = '李华';
update Y set cj = cj+10;
select * from Y;
deleteFROM Y whereid= 3;
select * FROM Y;
desc Y;
selectname ,cj FROM Y;
selectnameas 姓名,cj as'成 绩'FROM Y;
desc Y;
selectnameas 姓名,cj as 成绩 , casewhen cj>=90then'优秀'when cj >=80then'良好'else'差'endas 成绩 FROM Y;
selectnameas 姓名,cj as 成绩 , casewhen cj>=90then'优秀'when cj >=80then'良好'when cj >=70then'及格'else'差'endas 成绩评定 FROM Y;
selectnameas 姓名 ,cj+idas'总成绩'FROM Y;
selectdistinctnameas 姓名 from Y;
selectcount(*) as 总人数 FROM Y;
selectcount(cj) as 有成绩的人 FROM Y;
selectsum(cj) as 总成绩 FROM Y;
selectavg(cj) as 平均成绩 FROM Y;
selectmax(cj) as 最大值, min(cj) as 最小值 FROM Y;
selectvariance(cj) as 方差 FROM Y;
selectstddev(cj) as 标准差 FROM Y;
selectstd(cj) as 差 FROM Y ;
selectgroup_concat(name,cj) FROM Y where cj=90;
CREATETABLE y(
x int
);
insertinto y values(6);/*110*/insertinto y values(1);/*001*/selectbin(bit_and(x)) FROM y;/*只有有零就为零 000*/selectbin(bit_or(x)) FROM y;/*只要有一就为一 111*/selectbin(bit_xor(x)) FROM y;/*相同为零,不同为一 111*/