I understand that Oracle sysdate returns the current date AND time. That’s great for timestamp or datetime columns.
Now let’s say I have a DATE only column. What keywords should I use on my insert query?
insert into myTable1(myDateOnlyColumn) values(???)
And let’s say I have a TIME only column. What keywords should I use on my insert query?
insert into myTable2(myTimeOnlyColumn) values(???)
Thanks!
There is no such thing as a DATE only column in Oracle. The DATE datatype stores date and time.
If you only care about the date, you can:
This leaves the time component at 00:00:00. You don’t have to display it though.
If you’re only interested in the time component, you still have a date stored in the column. You’ll just have to handle that on output. For example:
Showing the actual contents of the column reveals a date was inserted:
Selecting only the time component from the column gives you the output you want:
If you think you need only a time column, you’ll want to make sure you always insert the same date component.