?
Solved

How to Safely Perform Data Type Conversion in an Oracle Table

Posted on 2011-03-17
1
Medium Priority
?
261 Views
Last Modified: 2012-05-11
Dear experts,

We are using Oracle 11 Database and we have more than a dozen of "very large" tables. All the tables have a field (column) with Time Stamp (3) type. How can we convert these fields to DATE type  in a safe way without recreating table?

Note: The truncation of the Time Stamp field (seconds fraction etc.) is not important. Year, Month, Date, Hour, Minutes are enough.

BR,

0
Comment
Question by:GurcanK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
qasim_md earned 1000 total points
ID: 35155706
1) you have to update your table with the UPDATE statement to eliminate the seconds fractions:
UPDATE TABLE1
SET date_column = convert(datetime,date_column)

2) After the table data is updated and the seconds fraction is removed ALTER the table column to the Datatype you want.

did that help ? let me know...
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question