问题描述
我在一个空表空间中有很多表,我想将这些表移动到另一个表空间。
我用这个脚本创建了表格
-- Create table
create table GSIB_BC_SUB_IDEN
(
sub_iden_id NUMBER(20) not null,sub_id NUMBER(20) not null,cust_id NUMBER(20) not null,network_type VARCHAR2(1),sub_iden_type VARCHAR2(4) not null,sub_identity VARCHAR2(64) not null,primary_flag VARCHAR2(1) not null,eff_date DATE not null,exp_date DATE not null,create_oper_id NUMBER(20),create_dept_id NUMBER(20),create_time DATE,modify_oper_id NUMBER(20),modify_dept_id NUMBER(20),modify_time DATE,upload_date DATE,file_name VARCHAR2(200)
)
partition by range (EFF_DATE)
(
partition GSIB_BC_SUB_IDEN_PAR_202101 values less than (TO_DATE(' 2021-02-01 00:00:00','SYYYY-MM-DD HH24:MI:SS','NLS_CALENDAR=GREGORIAN')),partition GSIB_BC_SUB_IDEN_PAR_202102 values less than (TO_DATE(' 2021-03-01 00:00:00',partition GSIB_BC_SUB_IDEN_PAR_202103 values less than (TO_DATE(' 2021-04-01 00:00:00',partition GSIB_BC_SUB_IDEN_PAR_202104 values less than (TO_DATE(' 2021-05-01 00:00:00',partition GSIB_BC_SUB_IDEN_PAR_202105 values less than (TO_DATE(' 2021-06-01 00:00:00',partition GSIB_BC_SUB_IDEN_PAR_202106 values less than (TO_DATE(' 2021-07-01 00:00:00',);
-- Create/Recreate primary,unique and foreign key constraints
alter table GSIB_BC_SUB_IDEN
add constraint PK_GSIB_BC_SUBIDEN primary key (SUB_IDEN_ID,EFF_DATE);
如何将表及其分区移动到 TB_DAT 表空间
运行此脚本但返回此错误
ALTER TABLE CBSPROD.GSIB_BC_SUB_IDEN MOVE TABLESPACE TB_DAT;
ORA-14511: 无法对分区对象执行操作
解决方法
SQL> alter table gsib_bc_sub_iden move partition GSIB_BC_SUB_IDEN_PAR_202101 tablespace users
2 /
Table altered.
SQL> alter table gsib_bc_sub_iden move partition GSIB_BC_SUB_IDEN_PAR_202102 tablespace users
2 /
Table altered.
SQL> alter table gsib_bc_sub_iden move partition GSIB_BC_SUB_IDEN_PAR_202103 tablespace users
2 /
Table altered.
SQL> alter table gsib_bc_sub_iden move partition GSIB_BC_SUB_IDEN_PAR_202104 tablespace users
2 /
Table altered.
SQL> alter table gsib_bc_sub_iden move partition GSIB_BC_SUB_IDEN_PAR_202105 tablespace users
2 /
Table altered.
SQL> alter table gsib_bc_sub_iden move partition GSIB_BC_SUB_IDEN_PAR_202106 tablespace users
2 /
Table altered.
,
以dba身份登录,alter table cbsprod.gsib_bc_sub_iden move tablespace dathw_idx;