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约束条件产生一个新的保单号,并将这个保单号插入数据表中。
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.