Alter table tablename add (column datatype [default value] [null/not null],...);
Alter table tablename modify (column datatype [default value] [null/not null],...);
Alter table tablename drop (column );
Alter table is used to add, delete, and modify a column.
The following is an example:
Create table test1
(Id varchar2 (20) not null );
Alter table test1
Add (name varchar2 (30) default 'Anonymous 'not null );
Alter table test1
Modify (name varchar2 (16) default 'unknown ');
Alter table test1
Drop column name;
Create a table, add, change, and delete a column. Note that if a value already exists in a column, an error will occur if you want to modify the column width to be narrower than these values.
For example, if we insert a value
Insert into test1
Values ('1', 'We love you ');
Then I modified the column: alter table test1.
Modify (name varchar2 (8 ));
The following error is returned:
ERROR is located in row 2nd:
ORA-01441: cannot reduce column length because some values are too large
PS: Change the column name of an existing table
Alter table table_name rename column col_old to col_new