(1) 在students表中,查詢年齡大於25歲,且爲男性的同窗的名字和年齡
(2) 以ClassID爲分組依據,顯示每組的平均年齡
(3) 顯示第2題中平均年齡大於30的分組及平均年齡
(4) 顯示以L開頭的名字的同窗的信息mysql
# 導入hellodb.sql mysql -uroot -p < hellodb_innodb.sql # 在students表中,查詢年齡大於25歲,且爲男性的同窗的名字和年齡 use hellodb; select name as 姓名,age as 年齡 from students where age > 25 and gender='M'; # 以ClassID爲分組依據,顯示每組的平均年齡 select ClassID as 班級,avg(Age) as 平均年齡 from students group by Classid; # 顯示第2題中平均年齡大於30的分組及平均年齡 select ClassID as 班級,avg(Age) as 平均年齡 from students group by Classid having avg(Age) > 30; # 顯示以L開頭的名字的同窗的信息 select * from students where name like 'L%';
# 建立magedu用戶而且設定密碼 create user magedu@'192.168.1.%' identified by '123456'; # 在另外一臺CentOS虛擬機登陸數據庫進行驗證 mysql -umagedu -p123456 -h192.168.1.12 # 使用hellodb數據庫 use hellodb;
MySQL最多見的存儲引擎包括InnoDB、MyISAMsql
InnoDB存儲引擎的特色:數據庫
MyISAM存儲引擎的特色:緩存