糯米文學吧

位置:首頁 > 計算機 > 計算機二級

2016計算機二級MYSQL數據庫模擬習題及答案

模擬訓練是為了讓考生提前熟悉考試流程和考試題型,可以讓考生提前適應考試的環境。以下是本站小編為大家整理的2016計算機二級MYSQL數據庫模擬習題及答案,希望對大家有幫助!

2016計算機二級MYSQL數據庫模擬習題及答案

  (一)單選題

1) SQL 2005 的字符串連接運算符是什麼?

A &

B .

C +

D _

2) SQL 2005中的比較運算符 不等於 有幾種表示方法?

A 1

B  2

C 3

D 4

3) !<在 SQL 2005中的含義是:

A 不等於

B 不小於

C 不大於

D 取反

4) 哪個是正確的小於等於號?

A >=

B =>

C <=

D =<

5) select substring(’長江長城黃山黃河’,2,2) 返回的是什麼?

A 長江

B 江長

C 長城

D 長江長城

6) varchar 類型的數據長度默認是__個字節?

A 1

B 2

C 4

D 8000

7) 若student 表中有一字段s_fenshu,數據類型為整型,保存每個學生的考試成績,求全班平均分的正確做法是:

A 把每個學生的 s_fenshu 手工進行相加,然後除以全班人數,得到平均分

B 使用 select avg(s_fenshu) from student

C 使用 select sum(s_fenshu) from student / select count(*) from student

D 使用 select sum(s_fenshu) from student % select count(*) from student

8) 100/3 的結果是:

A 33.33

B 33.333333

C 33

D 無法執行

9) 哪些是正確的' like 運算表達式?

A select * from net_46 where s_name like ’#曉#’

B select * from net_46 where s_name like ’&曉&’

C select * from net_46 where s_name like ’$曉$’

D select * from net_46 where s_name like ’%曉%’

10) 以下的數據庫中,哪個是大型的數據庫?

A MySql

B DB2

C Oracle

D MS Sql 2005

  參考答案:CBBCB ABCDC

  (二)代碼題

1) 寫代碼創建student數據庫 (滿分10)

數據庫裏建立數據表student_web

要求包含以下字段:

s_id 數據類型為整型,非空約束,

s_name 數據類型為可變字符型,最大長度12個字符,保存學生姓名

s_fenshu 數據類型為整型,

保存學生考試成績

s_hometown 數據類型為可變字符型,最大長度50個字符 保存學生籍貫

s_tuition 數據類型為整型

保存學生學費

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

id : 1    id : 2      id : 3

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

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

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

學費: 2800      學費: 3000     學費: 2700

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

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

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

6)寫代碼 返回所有學費低於平均學費的學生信息。提示使用嵌套的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)