Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Beginners Question.
On Sat, 17 Oct 1998 22:56:20 GMT, "dpinto"
<dpinto97_at_usa.net> wrote:
>I have a problem i have a table where i have a field that has a date
>but varchar2 and it looks like this 981231 actualy that is a date i
>need to update that to a date field, and at some point i need to insert
>it as a date field what should i do to accomplish that?
Do you need to turn this field into a DATE datatype? I don't think you can convert a VARCHAR2 directly to a DATE. You'll have to add another field, and use that instead. Do something like this:
alter table whatever add (new_date date); update whatever set new_date := to_date(old_date,'yymmdd'); commit;
Now you will have two date fields. Your original character date, and the new DATE date. Oracle does not currently provide a way to drop a field, so you either have to live with two fields in your table, and just use the new one, or you have to drop and recreate the entire table.
Jonathan Received on Sun Oct 18 1998 - 09:00:18 CDT