你有几种可能性。我更喜欢拥有最适合这项工作的数据类型。随着时代的计算最好使用DATE,TIMESTAMP和INTERVAL完成的,所以我会使用这样的:
SQL> create table visits
2 (startdate date
3 , starttime_tour interval day(0) to second(0)
4 , starttime_lunch interval day(0) to second(0)
5 , starttime_presentation interval day(0) to second(0)
6 , constraint visits_ck1 check (startdate = trunc(startdate))
7 )
8/
Table created.
你可以阅读更多有关INTERVAL DAY TO SECOND数据类型在这里:http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements001.htm#SQLRF00207
这里是一个例子是如何插入并从中选择:
SQL> insert into visits
2 values
3 (trunc(sysdate)
4 , to_dsinterval('0 09:00:00')
5 , to_dsinterval('0 12:00:00')
6 , to_dsinterval('0 13:00:00')
7 )
8/
1 row created.
SQL> select startdate
2 , starttime_tour
3 , starttime_lunch
4 , starttime_presentation
5 from visits
6/
STARTDATE STARTTIME_TOUR STARTTIME_LUNCH STARTTIME_PRESENTATI
------------------- -------------------- -------------------- --------------------
17-12-2010 00:00:00 +0 09:00:00 +0 12:00:00 +0 13:00:00
1 row selected.
,并计算现在是很容易的:
SQL> select startdate
2 , startdate + starttime_tour as tour
3 , startdate + starttime_lunch as lunch
4 , startdate + starttime_presentation as presentation
5 from visits
6/
STARTDATE TOUR LUNCH PRESENTATION
------------------- ------------------- ------------------- -------------------
17-12-2010 00:00:00 17-12-2010 09:00:00 17-12-2010 12:00:00 17-12-2010 13:00:00
1 row selected.
希望这有助于。
Regards, Rob。
谢谢抢劫! :D优秀。 :-) – Flukey 2010-12-17 13:57:40