複数カラム追加削除

 

(8.0.32)

drop table tab1;
create table tab1(col1 int,col2 int);
show create table tab1;

alter table tab1 add   col3 int ;
alter table tab1 add ( col4 int );
alter table tab1 add ( col5 int,col6 int );

alter table tab1 drop  col3 ;

カラム追加は複数同時実施可能
カラム削除は1カラムずつのみ可能★

alter table tab1 add ( col7 int,col8 int ), drop col4;

カラム追加とカラム削除の同時実行も可能

(19c)

drop table tab1 purge;
create table tab1(col1 int,col2 int);
desc tab1;

alter table tab1 add   col3 int ;
alter table tab1 add ( col4 int );
alter table tab1 add ( col5 int,col6 int );

alter table tab1 drop ( col3 );
alter table tab1 drop ( col4, col5 );


カラム追加は複数同時実施可能
カラム削除は複数同時実施可能

alter table tab1 add ( col7 int,col8 int ) drop ( col6 );

→ ORA-12987: 列の削除は他の操作と組み合せることはできません

カラム追加とカラム削除の同時実行は不可★

 

(15)

drop table tab1;
create table tab1(col1 int,col2 int);
\d tab1

alter table tab1 add col3 int ;
alter table tab1 add col4 int, add col5 int ;

alter table tab1 drop col3, drop col4 ;

カラム追加は複数同時実施可能
カラム削除は複数同時実施可能

alter table tab1 add col6 int ,add col7 int , drop col5;

カラム追加とカラム削除の同時実行も可能

 

(2022)

drop table tab1;
create table tab1(col1 int,col2 int);

sp_help tab1

 

alter table tab1 add col3 int ;
alter table tab1 add col4 int, col5 int ;

alter table tab1 drop COLUMN col3, col4 ;

※カラム削除時 COLUMNキーワードは必須

カラム追加は複数同時実施可能
カラム削除は複数同時実施可能

カラム追加とカラム削除の同時実行は不可★