How to define DEFAULT Option in CREATE TABLE

Database

How to define DEFAULT Option in CREATE TABLE

Hi,
I would like to define a formula in the DEFAULT value while creating a table. I need something like this:

CREATE TABLE MYTABLE (
ID INT,
CREATE_DT TIMESTAMP DEFAULT CURRENT_TIMESTAMP - INTERVAL '3' HOUR
)

That is: I need to store time value MINUS 3 hours in the CREATE_DT field.

Thanks.
2 REPLIES
N/A

Re: How to define DEFAULT Option in CREATE TABLE


As far to My knowledge in TD We cant do a operation in a default value.
we can give a constant value only.
N/A

Re: How to define DEFAULT Option in CREATE TABLE

I think Gogul is correct.
I have also not heard of this feature.
But lets see what others have to see.

I have a suggestion though.
Follow these sequence of steps
1. Insert into staging table via (any ETL utility)
2. Use BTEQ script and do an INSERT..SELECT
3. In the SELECT statement handle NULLS via CASE and your logic

I think this should work.

Vinay