tags:

views:

25

answers:

1

How can I add to a field in a Table built in Oracle database a time?

ex: I want to add the value 13:00:00 to the field Time in a table named Data

How can this be done?

I`m using Oracle 10g Express Edition

A: 

If this is one of the DATE field formats then for a record insert you would:

insert 
  into "DATA" ("TIME")
  values (to_date('13:00:00', 'HH24:MI:SS'));

You can verify this with:

select to_char("TIME", 'HH24:MI:SS')
from "DATA";
REW
this is not I was asking ... I don`t know what changed the title of the question, I re-edited it. I want to add time value to new row for example, I want to add the clock (1 PM) in the format HH:MM:SS to a column in a new row.
sikas
What is the format of the "TIME" field? Can you do a "DESCRIBE <TABLENAME>" for me?
REW
This is the SQL Command of my table:CREATE table "Schedule" ( "SID" NVARCHAR2(9) NOT NULL, "Code" NVARCHAR2(6) NOT NULL, "Room" NVARCHAR2(4) NOT NULL, "Day" NVARCHAR2(9) NOT NULL, "Time_From" TIMESTAMP NOT NULL, "Time_To" TIMESTAMP NOT NULL)
sikas
the type I`m working with is the TIMESTAMP
sikas
insert into "DATA" ("TIME") values (to_date('13:00:00','HH24:MI:SS')); this didn`t work. when I select the data from the table DATA all what I see is this data 01-JUN-10
sikas
Because your nls_date_format is set to 'DD-MON-YY' by default. If you want to see a date field in a different format then you will need to "to_char" it to the format you want:select to_char("time_from",'HH24:MI:SS') "time_from" from "Schedule";Also, TIMESTAMP is actually DATE + TIME, not just time, so when you assign just a time the date will have been assumed to some extent. DATE field is actually probably sufficient enough for you as it is, since DATE keeps precision to the second, and TIMESTAMP I believe is precision to the microsecond or higher.
REW