Add new column with default value and not null : Add Column « Table « Oracle PL/SQL Tutorial






SQL> create table registrations
  2  ( attendee    NUMBER(4)
  3  , course      VARCHAR2(6)
  4  , begindate   DATE
  5  , evaluation  NUMBER(1)
  6  , constraint  R_PK        primary key (attendee,course,begindate)
  7  ) ;

Table created.

SQL>
SQL>
SQL> alter table registrations
  2  add  (entered_by number(4) default 9 not null);

Table altered.

SQL>
SQL>
SQL> drop table registrations;

Table dropped.








6.21.Add Column
6.21.1.Add columns
6.21.2.Add a column with NOT NULL constraint
6.21.3.Add more columns
6.21.4.Add new column with default value and not null