I have created a table in oracle XE, and I have a field with type date. I would like if possible when I insert a row, that it automatically fills that field with the current date from the system.
I am inserting the rows from the SQL prompt.
Thanks
TIMESTAMP has a default of 0 unless defined with the NULL attribute, in which case the default is NULL .
Just use: select to_date(date_value, 'yyyy-mm-dd') as date_value from table; To convert to a date. That's it!
TO_DATE converts char of CHAR , VARCHAR2 , NCHAR , or NVARCHAR2 datatype to a value of DATE datatype. The fmt is a datetime model format specifying the format of char . If you omit fmt , then char must be in the default date format.
Here is how, you need to format your table properly:
create table test (first number , second timestamp default systimestamp , third varchar2(12));
And your default value is always current system time formatted as timestamp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With