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






Add new column with default value and not null

  

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.

   
    
  








Related examples in the same category

1.Add a char type column to a table
2.Add a date type column to a table
3.Alter table: add a column to an existing table
4.Add two columns to a table
5.Alter a table to add two columns and use select to check
6.Alter table to add two columns and then drop them
7.Alter table to add a column and then add constraint to it
8.Alter table to add a column and then add 'check' constraint to it
9.Alter table to add a primary key
10.Alter table to add varray type column
11.Alter table to add date type column
12.Add more columns