17,090
社区成员
发帖
与我相关
我的任务
分享
SQL> create table t(col_1 varchar2(10 char),col_2 date);
Table created
SQL>
SQL> insert into t(col_1,col_2)
2 values('qwertyuiop',to_date('2011-01-01','yyyy-mm-dd'));
1 row inserted
SQL> insert into t(col_1,col_2)
2 values('1023546.78',to_date('2010-05-04','yyyy-mm-dd'));
1 row inserted
SQL> commit;
Commit complete
SQL> alter table t modify col_1 number(10);
alter table t modify col_1 number(10)
ORA-01439: column to be modified must be empty to change datatype
SQL> alter table t modify col_1 varchar2(15);
Table altered
SQL> alter table t modify col_2 varchar2(15);
alter table t modify col_2 varchar2(15)
ORA-01439: column to be modified must be empty to change datatype
SSQL> alter table t modify col_1 varchar2(5);
alter table t modify col_1 varchar2(5)
ORA-01441: cannot decrease column length because some value is too big
SQL> create table t(col_1 number(5));
Table created
SQL> alter table t modify col_1 varchar2(10);
Table altered
SQL> --没有数据
--如果表中有数据,那么另外创建一个表
--将此表中的数据添加进去