學(xué)習(xí)第十一周

1、 導(dǎo)入hellodb.sql生成數(shù)據(jù)庫

  • (1) 在students表中,查詢年齡大于25歲,且為男性的同學(xué)的名字和年齡

select name,age from students where age>25 and gender = 'M';

  • (2) 以ClassID為分組依據(jù),顯示每組的平均年齡

select classid,avg(age) as 平均年齡 from students group by classid;

  • (3) 顯示第2題中平均年齡大于30的分組及平均年齡

select classid,avg(age) as 平均年齡 from students group by classid having avg(age)>30;

  • (4) 顯示以L開頭的名字的同學(xué)的信息

select * from students where name like 'L%';

2、數(shù)據(jù)庫授權(quán)magedu用戶,允許192.168.1.0/24網(wǎng)段可以連接mysql

create user magedu@'192.168.1.%' identified by '123456';
GRANT ALL PRIVILEGES ON *.* TO 'magedu'@'192.168.1.%'

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容