如何使用CTAS在Oracle表中创建TIMESTAMP(6)data_length 11?

时间:2017-11-12 00:04:36

标签: sql oracle

当我首先创建一个表时,它就出现了:

create table test (time timestamp(6));

Data_length = 11

"COLUMN_NAME" "DATA_TYPE"     "DATA_LENGTH"
"TIME"        "TIMESTAMP(6)"  11

但是当我做CTAS时:

 create table TEST as 
 select to_timestamp('09/09/17 04.07.25.086273', 'mm/dd/yy hh24:mi:ss.FF6')  time  
 from dual;

数据长度为20:

 select column_name, data_type, data_length 
 from all_tab_columns 
 where  owner =user and table_name='TEST';

"COLUMN_NAME" "DATA_TYPE"     "DATA_LENGTH"
"TIME"        "TIMESTAMP(6)"  20

如何在CTAS中获取data_length = 11?

1 个答案:

答案 0 :(得分:0)

刚想出其中一种方法:

CTAS运行后改变时间栏:

alter table TEST modify(time TIMESTAMP);

缩小到11字节

 select column_name, data_type, data_length 
 from all_tab_columns 
 where  owner =user and table_name='TEST';

"COLUMN_NAME" "DATA_TYPE"     "DATA_LENGTH"
"TIME"        "TIMESTAMP(6)"  11