0

I have the below ddl of the table fdg_USER

CREATE TABLE fdg_user (
  id          NUMBER(32,0)  NOT NULL, 
  updateddate TIMESTAMP(6)  NULL, 
  name        VARCHAR2(30)  NOT NULL,
  }

Now when I select all the columns ain few rows I see for the column name updated by is appearing as null I want to set the default values as name as bbb and default updateddate as 05.03.13 05:29:34

what I need to do this to add the default values for these two if they are null or if name is null then namedefault value should be insertes or if date is null then the date value is to be inserted

1
  • How did you get a name of NULL if your table clearly states NOT NULL? Commented Aug 1, 2013 at 16:50

2 Answers 2

1

You use default defaultvalue on each column when creating the table. See here : http://www.techrepublic.com/article/oracle-tip-how-to-use-default-values-with-database-columns/

It would look like this:

CREATE TABLE fdg_user (
    id          NUMBER(32,0) NOT NULL, 
    updateddate TIMESTAMP(6) DEFAULT TO_TIMESTAMP('05.03.13 05:29:34','dd.mm.yy hh24:mi:ss') NULL , 
    name        VARCHAR2(30) DEFAULT 'bbb' NOT NULL 
)

see sqlfiddle.

Sign up to request clarification or add additional context in comments.

Comments

0

This should do the trick

CREATE TABLE fdg_user (
    id NUMBER(32,0) NOT NULL, 
    updateddate TIMESTAMP(6) NULL DEFAULT "05.03.13 05:29:34", 
    name VARCHAR2(30)  NOT NULL DEFAULT "bbb"
)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.