in Oracle, (with pl-sql developer) How can I use a formatted default value in a column? (like this: to_char(sysdate, 'HH:MM:SS') )
I want create this coumns >>
name: f1
type: date
default: to_char(sysdate, 'HH:MM:SS')
in Oracle, (with pl-sql developer) How can I use a formatted default value in a column? (like this: to_char(sysdate, 'HH:MM:SS') )
I want create this coumns >>
name: f1
type: date
default: to_char(sysdate, 'HH:MM:SS')
Oracle doesn't have TIME only columns. Even if you set a column or variable to just HH24:MI:SS it will still have a date element.
The problem with just storing a time is that it is rarely useful without a date to go with it. So why not just store the datetime in a single column?
But if you really, really, really want just the time store the "seconds after midnight" as a number:
f1 number(5,0) default to_number(to_char(sysdate, 'sssss'))
Date type value does not depend on formatting.
Only when converting date to string, formatting is involved.
You can create formatted column of string values:
create table t (
id int,
f1 varchar2(20) default to_char(sysdate, 'HH24:MI:SS')
);