/*在mydb資料庫中創建student資料表,
表中有id、name(學生姓名)、math(數學成績)、chinese(語文成績)
和english(英語成績) 欄位。
然后創建視圖view_score,視圖中包含math、chinese、english和total(總分數)欄位。*/
/*解決msql中視圖不使用聚合函式的小問題。*/
/*代碼如下*/
use mydb;
/*創建student表*/
create table student(
id int PRIMARY KEY auto_increment comment 'id',
name varchar(10) not null comment '學生姓名',
math DECIMAL(4,1) not null comment '數學成績',
chinese DECIMAL(4,1) not null comment '語文成績',
english DECIMAL(4,1) not null comment '英語成績'
)DEFAULT CHARSET = utf8;
/*創建視圖view_score*/
create view view_score AS
select math,chinese,english,math+chinese+english total from student;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/103331.html
標籤:基礎類
上一篇:sql資料庫問題
下一篇:學技術,小白學什么合適
