Oracle  删除表中的列

CONN SCOTT/TIGER
DROP TABLE T1;
create table t1 as select * from emp;
insert into t1 select * from t1;
/
/
--到6000行,构造一个实验用大表T1。
COMMIT;

select EXTENT_ID,FILE_ID,BLOCK_ID,BLOCKS  from
dba_extents where SEGMENT_NAME='T1' AND OWNER='SCOTT';

--删除指定的一列
alter table t1 drop column hiredate;
alter table t1 move tablespace users;
select EXTENT_ID,FILE_ID,BLOCK_ID,BLOCKS  from
dba_extents where SEGMENT_NAME='T1' AND OWNER='SCOTT';

--禁用多列
alter table t1 set unused column comm;
alter table t1 set unused column sal;
alter table t1 set unused column mgr;
--验证是否释放空间
alter table t1 move tablespace users;
select EXTENT_ID,FILE_ID,BLOCK_ID,BLOCKS  from
dba_extents where SEGMENT_NAME='T1' AND OWNER='SCOTT';

--删除多列
alter table t1 drop unused columns;
--验证是否释放空间
alter table t1 move tablespace users;
select EXTENT_ID,FILE_ID,BLOCK_ID,BLOCKS  from
dba_extents where SEGMENT_NAME='T1' AND OWNER='SCOTT';

Oracle 删除表中的列-LMLPHP

05-13 08:08