Search code examples
sqlexceldefault-value

Is there any ways to implement in oracle sql column default, like today() in excel?


Is there any possible way to make the column in sql oracle be like today() function in excel. Which will be show the today's date. I've tried using "SYSDATE" in the default value column but it does not change day by day means it only take the submission date. default value column I need it changes to the current date.


Solution

  • You need to select the column. The default value is assigned when a row is inserted.

    One method would use a view:

    create view v_t as
        select t.*, trunc(sysdate) as today
        from t;
    

    If you want the value in a particular format, either set the format in Excel or use to_char(), such as to_char(sysdate, 'MM/DD/YYYY').