top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to add column in existing oracle table with not null constraint

+1 vote
773 views

I am using below statement but i got error.
ALTER TABLE XXXtable
ADD xxx_name varchar2(50) not null;

error message:
ORA-01758: table must be empty to add mandatory (NOT NULL) column

posted Sep 11, 2014 by Arun Gowda

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

ALTER TABLE XXXtable
ADD xxx_name varchar2(50) not null;

add a default value clause along with your alter table.
with that, although the new column is not null, and already has a value assigned to it through the default clause.

answer Sep 11, 2014 by Raghvendra Sharma
0 votes

Hi Arun,

below is the syntax for query

ALTER TABLE emp
ADD supplier_name varchar2(50) default ('A') not null;

answer Sep 12, 2014 by Archana
Similar Questions
+1 vote

I have a Time column in my SQL Server table which has data like (14:00:00.0000000).

I am trying to load this type of data in Oracle table which has corresponding column datatype as timestamp. I am trying to convert the time column in SQL server to timestamp column in oracle using Informatica.

Whats the best way to do it?

...