>全國計算機等級考試題庫大全  (二)代碼題: 要求代碼完整,每錯一個單詞扣一分.每出現(xiàn)一次不匹配的( ) 扣兩分,(總分40分)  1) 寫代碼創(chuàng)建student數(shù)據(jù)庫 (滿分10)  數(shù)據(jù)庫里建立數(shù)據(jù)表student_web  要求包含以下字段:..." />

国产18禁黄网站免费观看,99爱在线精品免费观看,粉嫩metart人体欣赏,99久久99精品久久久久久,6080亚洲人久久精品

2015年計算機二級mysql數(shù)據(jù)庫模擬試題及答案(4)

時間:2015-01-28 14:17:00   來源:無憂考網(wǎng)     [字體: ]
點擊查看>>全國計算機等級考試題庫大全

  (二)代碼題: 要求代碼完整,每錯一個單詞扣一分.每出現(xiàn)一次不匹配的( ) 扣兩分,(總分40分)

  1) 寫代碼創(chuàng)建student數(shù)據(jù)庫 (滿分10)

  數(shù)據(jù)庫里建立數(shù)據(jù)表student_web

  要求包含以下字段:

  s_id 數(shù)據(jù)類型為整型,非空約束,

  s_name 數(shù)據(jù)類型為可變字符型,長度12個字符,保存學(xué)生姓名

  s_fenshu 數(shù)據(jù)類型為整型,

  保存學(xué)生考試成績

  s_hometown 數(shù)據(jù)類型為可變字符型,長度50個字符 保存學(xué)生籍貫

  s_tuition 數(shù)據(jù)類型為整型

  保存學(xué)生學(xué)費

  2)寫代碼 向上題所創(chuàng)建好的數(shù)據(jù)表中添加以下三條記錄,(滿分9)

  id : 1    id : 2      id : 3

  姓名: Jack Tomas   姓名: Tom Joe   姓名: Smiths

  成績: 89       成績: 88      成績: 87

  籍貫: 北京豐臺    籍貫: 天津南開   籍貫: 北京海濱

  學(xué)費: 2800      學(xué)費: 3000     學(xué)費: 2700

  3)寫代碼 返回所有學(xué)生的信息 (滿分3)

  4)寫代碼 返回所有姓名帶J字母的學(xué)生信息!(滿分5)

  5)寫代碼 返回所有北京籍貫的學(xué)生信息 (滿分5)

  6)寫代碼 返回所有學(xué)費低于平均學(xué)費的學(xué)生信息。提示使用嵌套的select查詢 (滿分8)

  代碼答案:(如下)

  1)

  create database student

  use student

  create table student_web

  (

  s_id int not null,

  s_name varchar(12),

  s_fenshu int,

  s_hometown varchar(50),

  s_tuition int

  )

  2)

  insert into student_web (s_id,s_name,s_fenshu,s_hometown,s_tuition)

  values(1,’Jacktomas’,89,’北京豐臺’,2800)

  insert into student_web (s_id,s_name,s_fenshu,s_hometown,s_tuition)

  values(1,’TomJoe’,88,’天津南開’,3000)

  insert into student_web (s_id,s_name,s_fenshu,s_hometown,s_tuition)

  values(1,’Smiths’,87,’北京海濱’,2700)

  3)

  select * from student_web

  4)

  select * from student_web where s_name like ’%J%’

  5)

  select * from student_web where s_hometown=’北京%’

  6)

  select * from student_web where s_tuition<(select avg(s_tuition) from s_tuition)