11 Replies Latest reply: Jul 19, 2013 7:18 AM by kiran_oracle RSS

    Please let me know how  I can add a new column with not  null constraint,table already has data ,without  table dropping  ...Please  help  me on this  issue....

    kiran_oracle

      Hi 

       

      I  have  a table  emp_job_det with  a,b,c  columns . note  that this TABLE ALREADY  HAS  DATA  FOR  THESE COLUMNS

       

      NOW iam adding  a new column "D" with not  null constraint

       

      Fistly  I  alter  table   by  adding  column only "D",  if i do so  the whole  column  would be created with alll null values for  D column BY  DEFAULT

       

      alter  table emp_job_det add D number ; ---- note not  null CONSTRAINT  is  not  added

       

      secondly... if I try  adding  not  null constraint , will throw an eoor  bcoz already  conatained null values...

       

                                             ( OR)

       

       

      In another  way ,  If i put the query

       

      alter  table  emp_job_det  add   D number NOT NULL; ----- THROWS ERROR AS TABLE ALREADY  CONTAINS DATA

       

      So my  ques is how can how  I can add a new column with not  null constraint,table already has data ,without  table dropping

      Please  help  me on this  issue....