一、选择题:
1、在MS SQL Server中,用来显示数据库信息的系统存储过程是()
A sp_ dbhelp
B sp_ db
C sp_ help
D sp_ helpdb

2、SQL语言中,删除一个表的命令是( )
A DELETE
B DROP
C CLEAR
D REMORE

3、关系数据库中,主键是(__)
A、为标识表中唯一的实体
B、创建唯一的索引,允许空值
C、只允许以表中第一字段建立
D、允许有多个主键的

4、在Transact-SQL语法中,SELECT语句的完整语法较复杂,但至少包括的部分(1___),使用关键字(2___)可以把重复行屏蔽,将多个查询结果返回一个结果集合的运算符是(3___),如果在SELECT语句中使用聚合函数时,一定在后面使用(4___)。
     ⑴ A、SELECT,INTO               B、SELECT,FROM
      C、SELECT,GROUP            D、仅SELECT
   ⑵ A、DISTINCT                          B、UNION
        C、ALL                                  C、TOP
   ⑶ A、JOIN                                B、UNION
         C、INTO                               C、LIKE
   ⑷ A、GROUP BY                       B、COMPUTE BY
        C、HAVING                           D、COMPUTE

5、语句DBCC SHRINKDATABASE (Sample, 25)中的25表示的意思是
A、25M
B、剩余占整个空间的25%
C、已用空间占整个空间的25%
D、以上都不对

6、你是一个保险公司的数据库开发人员,公司的保单信息存储在SQL Server 2000数据库中,你使用以下脚本建立了一个名为Policy的表:
CREATE TABLE Policy
(
PolicyNumber int NOT NULL DEFAULT (0),
InsuredLastName char (30) NOT NULL,
InsuredFirstName char (20) NOT NULL,
InsuredBirthDate datetime NOT NULL,
PolicyDate datetime NOT NULL,
FaceAmount money NOT NULL,
CONSTRAINT PK_Policy PRIMARY KEY (PolicyNumber)
)
每次公司销售出一份保单,Policy表中就增加一条记录,并赋予其一个新的保单号,你将怎么做?

a.建立一个INSTEAD OF INSERT触发器来产生一个新的保单号,并将这个保单号插入数据表中。
b.建立一个INSTEAD OF UPDATE触发器来产生一个新的保单号,并将这个保单号插入数据表中。
c.建立一个AFTER UPDATE触发器来产生一个新的保单号,并将这个保单号插入数据表中。
d.用AFTER UPDATE触发器替代DEFAULT约束条件产生一个新的保单号,并将这个保单号插入数据表中。

7、在SQL语言中,如果要建立一个工资表包含职工号,姓名,职称。工资等字段。若要保证工资字段的取值不低于800元,最合适的实现方法是:
A。在创建工资表时为”工资“字段建立缺省
B。在创建工资表时为”工资“字段建立检查约束
C。在工资表建立一个触发器
D。为工资表数据输入编写一个程序进行控制

8、Select 语句中用来连接字符串的符号是______.
A. “+” B. “&” C.“||” D.“|”

9、你是一个出版公司的数据库开发人员,对特定的书名的每天的销售情况建立了如下的存储过程:
CREATE PROCEDURE get_sales_for_title
title varchar(80), @ytd_sales int OUTPUT
AS
SELECT @ytd_sales = ytd_sales
FROM titles
WHERE title = @title
IF @@ROWCOUNT = 0
RETURN(-1)
ELSE
RETURN(0)
另外建立了一个脚本执行这个存储过程,如果执行成功,将返回对应于书名的每天的销售情况的报表,如果执行失败,将返回“No Sales Found”,怎样建立这个脚本?

A. DECLARE @retval int
DECLARE @ytd int
EXEC get_sales_for_title ‘Net Etiquette’, @ytd
IF @retval < 0
PRINT ‘No sales found’
ELSE
PRINT ‘Year to date sales: ’ + STR (@ytd)
GO

B. DECLARE @retval int
DECLARE @ytd int
EXEC get_sales_for_title ‘Net Etiquette’, @ytd OUTPUT
IF @retval < 0
PRINT ‘No sales found’
ELSE
PRINT ‘Year to date sales: ’ + STR (@ytd)
GO

C. DECLARE @retval int
DECLARE @ytd int
EXEC get_sales_for_title ‘Net Etiquette’,@retval OUTPUT
IF @retval < 0
PRINT ‘No sales found’
ELSE
PRINT ‘Year to date sales: ’ + STR (@ytd)
GO

D. DECLARE @retval int
DECLARE @ytd int
EXEC @retval = get_sales_for_title ‘Net Etiquette’, @ytd OUTPUT
IF @retval < 0
PRINT ‘No sales found’
ELSE
PRINT ‘Year to date sales: ’ + STR (@ytd)
GO

10、You are a database developer for a container manufacturing company. The containers produced by your company are a number of different sizes and shapes. The tables that store the container information are shown in the Size, Container, and Shape Tables exhibit:
Size
SizeID
SizeName
Height
Container
ContainerID
ShapeID
SizeID
Shape
ShapeID
ShapeName
Measurements







A sample of the data stored in the tables is shown below:
Size Table
SizeID        SizeName        Height
1             Small           40
2             Medium          60
3             Large           80
4             Jumbo           100
Shape Table
ShapeID   ShapeName   Measurement
1         Triangle        10
2         Triangle        20
3         Triangle        30
4         Square          20
5         Square          30
6         Square          40
7         Circle          15
8         Circle          25
9         Circle          35
Periodically, the dimensions of the containers change. Frequently, the database users require the volume of a container. The volume of a container is calculated based on information in the shape and size tables.
You need to hide the details of the calculation so that the volume can be easily accessed in a SELECT query with the rest of the container information. What should you do?
A.    Create a user-defined function that requires ContainerID as an argument and returns the volume of the container.
B.    Create a stored procedure that requires ContainerID as an argument and returns the volume of the container.
C.    Add a column named volume to the container table. Create a trigger that calculates and stores volume in this column when a new container is inserted into the table.
D.    Add a computed column to the container table that calculates the volume of the container.

二、填空题
1、 备份策略的三种类型是__________备份,_______________备份,___________________备份组成。
2、 启动一个显式事务的语句为__________,提交事务的语句为__________,回滚事务的语句为__________
三、简答题
1、 现有1销售表(表名为SellDetail),它们结构如下:(4分)
字段名 字段类型 说明
id int (标识号)
codno char(7) (商品编码)
codname       varchar(30) (商品名称)
spec                        varchar(20) (商品规格)
price           numeric(10,2) (价格 )
sellnum int (销售数量)
deptno                    char(3) (售出分店编码)
selldate                    datetime (销售时间)
要求:写出查询销售时间段在2002-2-15日到2002-4-29之间,分店编码是01的所有记录。
2、写一个存储过程,要求传入一个表名,返回该表的记录数(假设传入的表在数据库中都存在)

原文地址:http://www.javaeye.com/topic/137688

posted on 2009-07-11 05:26  阿C's  阅读(488)  评论(1编辑  收藏  举报