SQL触发器 [英] SQL Trigger
本文介绍了SQL触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是sql的新手,作为作业的一部分,我必须创建触发器以满足业务规则。
第一个商业规则是:
>
确保持续五天的巡航不能在12月运行。
与此触发器相关的两列在两个单独的表中,我不确定是否这将导致任何问题。
如果有人可以帮助或指出我正确的方向那么这将是伟大的!
谢谢
解决方案
是的,我认为这是可能的。
请提供表格定义和可能的数据样本。
有我的桌子:
Cruise(CruiseNO,姓名,持续时间,费用,港口)
预订(CruiseNO *,客户ID *,VoyageID *,CabinNo,Class,评估)
客户(客户ID,客户名称,性别,电话号码,地址)
发货(ShipID,ShipName,Port,tonnage)
Voyage(Voyage_ID,Startdate ,Starting_Location,ShipID *
以下是航行中的一些样本数据
(1,'' - 17 -MAR-2007 '',''雅典'',1)
(2,'' - 20-APRIL-2006'',''那不勒斯'',2)
以下是游轮的一些样本数据
(1,''Dream Way'',2,600,''那不勒斯'')
(2,''HotHotHot'',3,2000,''Blackpool'');
任何帮助都会很棒,感谢您抽出时间
我没有看到Voyage和Cruise之间的关系。
如果我理解正确,我们必须检查Cruise中的持续时间以及是否为5然后在12月拒绝使用StartDate进入Voyage
I am fairly new to sql and as part of an assignment I have to create triggers to satisfy business rules.
The first business rule is:
ensure that cruises of five days duration cannot be run in December.
the two columns that are relevant to this trigger are in two separate tables and I am not sure if this will cause any problems.
If anyone can help or point me in the right direction then this would be great!
Thanks
解决方案
Yes, I think it is possible.
Please, provide table definitions and possible data sample.
There are my tables:
Cruise(CruiseNO, Name, Duration, Cost, Ports)
Booking(CruiseNO *, CustomerID*, VoyageID*, CabinNo, Class, Evaluation)
Customer (CustomerID, CustomerName, Gender, Telephonenumber, address)
Ship(ShipID, ShipName, Port, tonnage)
Voyage(Voyage_ID, Startdate, Starting_Location, ShipID*
Here is some sample data from voyage
(1, ''17-MAR-2007'', ''Athens'', 1)
(2, ''20-APRIL-2006'', ''Naples'', 2)
Here is some sample data from cruise
(1, ''Dream Way'' , 2, 600 , ''Naples'');
(2, ''HotHotHot'', 3 , 2000 , ''Blackpool'');
Any help would be great, thanks for taking the time out
I don''t see relation between table Voyage and Cruise.
If I understand it correctly we have to check Duration in Cruise and if it is 5 then reject entree into Voyage with StartDate in December.
这篇关于SQL触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文