2014-11-25 92 views
0

我有兩個表,其中我有一列包含日期和時間在一個表中的類型是DATE。在oracle11g中插入日期和時間

我應該在另一個表中使用什麼類型的表格來將前表中列的值與日期和時間一起插入到此表中。

我試過日期但時間變了CHANGED.I不想使用字符串。

+0

你是什麼意思與「*時間變得*」。請向我們展示您的SQL代碼(和存儲過程) – 2014-11-25 09:13:47

+0

「時間得到改變」意味着即時值獲取時間值插入到新表中。我需要在前者的時間 – theDbGuy 2014-11-25 09:19:05

+1

請向我們展示您的代碼(包括你的存儲過程)。我發現_very_很難相信。 – 2014-11-25 09:20:03

回答

1

我認爲你有一個顯示問題或者你不正確地複製日期字段。它應該工作。見我的例子:

set line 250 
create table table1 (dt date); 
insert into table1 values (to_date('24/11/2014 23:01','DD/MM/YYYY HH24:MI')); 
insert into table1 values (to_date('25/11/2014 11:02','DD/MM/YYYY HH24:MI')); 
create table table2 (dt date); 
select * from table1; 
select to_char(dt,'DD-MM-YYYY HH24:MI:SS') from table1; 
insert into table2 select * from table1; 
select * from table2; 
select to_char(dt,'DD-MM-YYYY HH24:MI:SS') from table2; 
drop table table1; 
drop table table2; 

輸出

Table created. 
1 row created. 
1 row created. 
Table created. 

DT  
--------- 
24-NOV-14 
25-NOV-14 

2 rows selected. 

TO_CHAR(DT,'DD-MM-YYYYHH24:MI:SS') 
---------------------------------- 
24-11-2014 23:01:00    
25-11-2014 11:02:00    

2 rows selected. 
2 rows created. 

DT  
--------- 
24-NOV-14 
25-NOV-14 

2 rows selected. 

TO_CHAR(DT,'DD-MM-YYYYHH24:MI:SS') 
---------------------------------- 
24-11-2014 23:01:00    
25-11-2014 11:02:00    

2 rows selected. 
Table dropped. 
Table dropped. 

它不會自動顯示你的時間,但截斷。

相關問題