當前位置:才華齋>計算機>計算機二級>

2016計算機二級MYSQL資料庫模擬習題及答案

計算機二級 閱讀(3.02W)

模擬訓練是為了讓考生提前熟悉考試流程和考試題型,可以讓考生提前適應考試的環境。以下是本站小編為大家整理的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)