1. SQL Server 2000是典型的關系型資料庫產品。 ( 1 )
2. 在一台計算機上可以同時運行多個版本的SQL Server。 ( 1 )
3. 在SQL Server中日誌文件是維護資料庫完整性的重要工具。 ( 0 )
4. 在定義數據表時,定義某列為標識列的關鍵字是Identity。 ( 1 )
5. 浮點數據類型的優點是能夠存儲范圍非常大的數字,但容易發生誤差。 ( 0 )
6. 資料庫完整性的目的是為了防止錯誤信息輸入和輸出。 ( 0 )
7. 在Update語句中,一次可以更新多個表。 ( 0)
8. 盡量使用Select * ,可以加快查詢速度。 ( 0 )
9. 在SQL Server 2000中表示注釋可以用類似C語言的/*...*/和//。 ( 0 )
10. 在SQL Server中,RTRIM函數刪除字元串右邊的空白字元。 ( 1 )
11. 一個表只能有一個聚集索引(簇索引)。 ( 1 )
12. SQL查詢語言中,如果沒有指定排序方式,則默認是升序方式。 ( 1 )
13. 在SQL Server 2000中ntext類型的欄位不能進行排序操作。 ( 0 )
14. 在SQL Server 2000中bit類型的欄位不能建立索引。 ( 1 )
15. 在被定義為唯一索引的列上的數據不能有重復的值。 ( 1 )
16. 在被定義為唯一索引的列上的數據不允許空。 ( 0可以的但是只能有一個null值 )
17. 在SQL Server中,每張表都應該建立一個索引,以提高查詢速度。 ( 0 )
18. 視圖在SQL Server中是一張虛擬表。 ( 1 )
19. 當一個視圖由2個以上基本表構成時,不能進行刪除視圖中的數據。 ( 0 )
20. 在SQL Server中,觸發器是一種特殊的存儲過程。 ( 1 )
21. 由於存儲過程是解釋執行,所以每次執行時都要檢查是否有語法錯誤。 ( 0 )
22. 可以在用戶正在使用的資料庫上執行資料庫恢復操作。 ( 0 )
1表示正確
② 簡單的SQL語句練習,最好給出解釋
1D 2B 3A 初步答案,你試試
③ SQL資料庫練習題~
1.select name from 學生
where 系別='數學系' and 性別='女';
2.select a.name from 學生 a inner join 選課 b
on a.學號=b.學號
where 成績<60;
3.select a.name from 學生 a inner join 選課 b
on a.學號=b.學號
where avg(成績)>=95;
4.select a.name from 學生 a inner join 選課 b
on a.學號=b.學號
where (select b.成績 from 課程 c inner join 選課 b
on c.課程號=b.課程號 where 課程名='SQL Server 2000')<60
5.update 學生
set 年齡=年齡+1;
④ SQL語句 習題拜託大家啦!!
A,B,C,C(關系模型資料庫結構應該是二維表,無正確選項選項錯誤),A,B,C,D,D,D,A,B,A.
給分噢。保你100分。只是你第四道題,沒有答案。
⑤ 關於SQL命令的練習題,急急急!!!
select * from 專業表
select * from 課程表 where ID='000001' order by 成績 desc
select avg(成績) from 成績表 group by 課程 where 人數>1
select count(人數),max(成績),min(成績),avg(成績) from 成績表 group by 課程 where 成績 is not null
select count(課程) from 成績表 group by 學號
sleect * from 學生信息表 join 成績表 on 學號=學號
⑥ SQL數據查詢練習
--1.1創建新表 score
create table score
(
[學號] varchar(10)
,[課程號] varchar(10)
,[成績] float
)
--1.2插入新表的值
insert into score values(103,'3-245',86)
insert into score values(105,'3-245',75)
insert into score values(109,'3-245',68)
insert into score values(103,'3-105',92)
insert into score values(105,'3-105',88)
insert into score values(109,'3-105',76)
insert into score values(101,'3-105',64)
insert into score values(101,'3-105',64)
insert into score values(101,'6-166',85)
insert into score values(107,'6-166',79)
insert into score values(108,'6-166',81)
--1.3 按排列順序查看創建的表的內容
select* from score order by [課程號] asc,[成績] desc --這樣查看不舒服,可以修改下,如下面這句:
select [課程號],[成績],[學號] from score order by [課程號] asc,[成績] desc
--1.4
select y=sum([成績]) --查找3-105 的分數之和,問題6-166的總分也是這個道理
, x=count([課程號]) from score where [課程號]='3-105'--查找3-105的課程個數
--計算平均分
select [3-105平均分]=y/x from(select y=sum([成績])
, x=count([課程號]) from score where [課程號]='3-105')t
--1.5 查詢成績為定值的記錄
select * from score where [成績]='85' or [成績]='86' or [成績]='88'
--這里用and 的話沒法查出內容,
--1.6 成績在多少到多少的記錄
select * from score where [成績] between 60 and 79 order by [成績] desc
--1.7查詢每個學生的最高分
select * from score where [成績] in(select max([成績]) from score group by [學號])
--1.8課程最高分
select * from score where [成績] in(select max([成績]) from score group by [課程號])
--各門課程最高分大於90的就是在上面的內容上增加一個where 條件,自己嘗試下
select * from(select * from score where [成績] in(select max([成績]) from score group by [課程號]))t
where [成績]>=90
--注意資料庫別名的用法't'
--1.9弟九個問題跳過,扯蛋的問題
--2.0課程次數及排序
select [課程號],[課程次數]=count([課程號]) from score group by [課程號] order by 課程次數 desc
--注意資料庫自定義欄位的使用
--升序 asc ,降序 desc
--2.1最後一個問題你自己考慮考慮,方法基本都在前面幾個問題裡面可以找到。
⑦ SQL的練習,求答案!!!
/*創建Moonfox_db資料庫*/
use master
if exists(select * from sysdatabases where name='Moonfox_db')
drop database Moonfox_db
create database Moonfox_db
on
(
name='Moonfox_db_data',
filename='D:\Visual Studio 2008 & Sql server 2005\Sql server\Moonfox_db.mdf',
size=10,
filegrowth=2MB
)
log on
(
name='Moonfox_db_log',
filename='D:\Visual Studio 2008 & Sql server 2005\Sql server\Moonfox_db.ldf',
size=5,
filegrowth=20%
)/*創建Department表*/
use Moonfox_db
if exists(select * from sysobjects where name='Department')
drop table Department
create table Department
(
DID int identity (1,1)primary key,--部門編號,主鍵
Dname nvarchar(20),--部門名稱
Address nvarchar(50),--部門地址
Photo decimal(12,0),--電話
)/*創建Employee表*/
use Moonfox_db
if exists(select * from sysobjects where name='Employee')
drop table Employee
create table Employee
(
EID int identity (1,1)primary key,--職工編號,主鍵
Ename varchar(10),--職工名
Gender nchar(2) check(Gender='男' or Gender='女'),--性別,添加限制
Position nvarchar(10) check(Position='員工' or Position='組長' or Position='經理'),--職務,添加限制
Address nvarchar(50),--家庭地址
DID int,--部門編號,外鍵
foreign key(DID) references Department(DID)--外鍵約束
)
/*創建Care表*/
use Moonfox_db
if exists(select * from sysobjects where name='Care')
drop table Care
create table Care
(
CID int identity (1,1)primary key,--保健卡編號,主鍵
EID int,--職工號,外鍵
foreign key(EID) references Employee(EID),--外鍵約束
CheckDate datetime,--檢查身體日期
PhysicalCondition nvarchar(4) check(PhysicalCondition='一般' or PhysicalCondition='差' or PhysicalCondition='好'),--健康狀況
)
/*創建Care表約束*/
alter table Care
add
constraint DF_CheckDate default(getdate()) for CheckDate--預設,默認凈時間為當前計算機時間 路徑自己修改,試圖自己做,選擇語句自己寫。我該睡覺了,抱歉,你試著在sql server中運行下,我等著休息,也不知道寫的有沒有錯誤,沒時間幫你寫省下的了。不急著用的話我明天幫你寫吧。
⑧ sql練習!!!
alter talbe stuscore
add constraint ch_a check(english<100 and english>0)
select * from stuinfo where name like '張%' and sex = '男'
select time from stuinfo where name = '劉k'
……………………
……………………
只能到這里了,僅供參考