create table t1 ( id number, col1 varchar2(100), col2 varchar2(100), col3 generated always as (id+100) virtual ) partition by range (id) ( partition p1 values less than (200), partition p2 values less than (400) );
xb@PDB12C> @desc t1 Name Null? Type ------------------------------- -------- ---------------------------- 1 ID NUMBER >>>>====已经看不到col1和col2两个字段 2 COL3 NUMBER
col column_name for a40 col data_type for a20 col data_length for 999999999999 col data_default for a20 col virtual_column for a20 SELECT column_name, data_type, data_length, data_default, virtual_column FROM user_tab_cols WHERE table_name = 'T1';
COLUMN_NAME DATA_TYPE DATA_LENGTH DATA_DEFAULT VIRTUAL_COLUMN ---------------------------------------- -------------------- ------------- -------------------- -------------------- ID NUMBER 22 NO SYS_C00002_19031410:18:00$ VARCHAR2 100 NO COL2 VARCHAR2 100 NO COL3 NUMBER 22 "ID"+100 YES
drop table t2 purge; create table t2 as select * from t1 where 1=2; create index idx_t2 on t2(id);
COLUMN_NAME DATA_TYPE DATA_LENGTH DATA_DEFAULT VIRTUAL_COLUMN ---------------------------------------- -------------------- ------------- -------------------- -------------------- ID NUMBER 22 NO COL3 NUMBER 22 NO >>>>====新表字段并非虚拟列
insert into t2 select level from dual connect by rownum>=200;
commit;
alter table t1 exchange partition p1 with table t2 without validation update global indexes;
ERROR at line 3: ORA-14096: tables in ALTER TABLE EXCHANGE PARTITION must have the same number of columns
create table t2 for exchange with table t1; create index idx_t2 on t2(id);
col column_name for a40 col data_type for a20 col data_length for 999999999999 col data_default for a20 col virtual_column for a20 SELECT column_name, data_type, data_length, data_default, virtual_column FROM user_tab_cols WHERE table_name = 'T2';
COLUMN_NAME DATA_TYPE DATA_LENGTH DATA_DEFAULT VIRTUAL_COLUMN ---------------------------------------- -------------------- ------------- -------------------- -------------------- COL2 VARCHAR2 100 NO SYS_C00002_19031410:18:00$ VARCHAR2 100 NO ID NUMBER 22 NO COL3 NUMBER 22 "ID"+100 YES