0

我已经用日期加载了日期字段,类型是 varchar。

如何在显示字段时在 oracle express/sql 加载器中将日期字段(varchar)转换为日期字段(日期)?

4

1 回答 1

0

You can't change the data type of a column in a permanent table from VARCHAR2 to DATE when it has data.

You can, however, add a new column

ALTER TABLE table_name
  ADD( new_date_column DATE );

move the data over

UPDATE table_name
   SET new_date_column = to_date( old_varchar2_column, format_mask );

drop the old column

ALTER TABLE table_name
  DROP COLUMN old_varchar2_column;

and then rename the new column to the old column name

ALTER TABLE table_name
  RENAME COLUMN new_date_column TO old_column_name

Of course, once you do this, you'll need to change your SQL*Loader script to convert the data to a DATE if you ever want to load into this table again.

于 2013-07-15T21:21:28.213 回答