Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Beginners Question.

Re: Beginners Question.

From: Jonathan Gennick <gennick_at_worldnet.att.net>
Date: 18 Oct 1998 14:00:18 GMT
Message-ID: <362bf3a1.17334945@netnews.worldnet.att.net>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US