Converting tables from CHAR to VARCHAR2

From: Brian M. Biggs <bbiggs_at_cincom.com>
Date: 1996/01/23
Message-ID: <31057888.54D_at_cincom.com>#1/1


We have 250+ tables in our Oracle 7.1 application, and they all use CHAR datatypes instead of VARCHAR2. We are now looking at converting them to VARCHAR2, and were wondering what the easiest way is to do this.

We can create new CREATE TABLE statements with no problems, but how do you migrate data in existing tables (defined as CHAR) to the new format (as VARCHAR2). Does export/import automatically make the conversion for you if you export, drop the tables, redefine them as VARCHAR2, and re-import (I doubt it, but was hoping...)?

Here are my thoughts on how to approach this. Does anyone have suggestions on which approach would be the best, or at least be the path of least resistance? This is something we will have to provide for our customers as well as for our own internal use, so it should be as flexible as possible.

  1. Create a second set of the tables using VARCHAR2. INSERT INTO the new tables from the old tables. Would probably work, but could cause rollback problems on larger tables. We would also have to right trim all CHAR columns in the INSERT statement. Yech!
  2. Write a dynamic SQL package/procedure/whatever to go through the entire database and transfer the data. Seems rather messy.
  3. Write Pro* language programs to extract data into flat files, right trim appropriate columns, and re-load using SQL*Loader. Might be the easiest option, since we already have SQL*Loader control files created. But, the extract programs might be cumbersome to write because of the large number of tables and columns.

Thanks in advance,
Brian

-- 
Brian M. Biggs                             mailto:bbiggs_at_cincom.com
Cincom Systems, Inc.                       voice: (513) 677-7661
http://www.cincom.com/
Received on Tue Jan 23 1996 - 00:00:00 CET

Original text of this message