DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: data conversion from char(4) data to char(2)

Hybrid View

  1. #1
    Join Date
    Nov 2001
    Location
    Singapore
    Posts
    182

    data conversion from char(4) data to char(2)

    I have table called packagelines contains 3220 records
    SQL> desc packagelines;
    Name Null? Type
    ----------------------------------------- -------- --------------
    CORP NOT NULL NUMBER(2)
    PKG NOT NULL CHAR(2)
    PKGSTOP NOT NULL CHAR(6)
    LINE NOT NULL CHAR(4)
    RCODE NOT NULL CHAR(2)

    Now i want to reduce the size of a column LINE CHAR(4) to CHAR(2).How can i do it.
    only two character data is present in the column LINE
    J Gangadhar

  2. #2
    Join Date
    Nov 2000
    Location
    Birmingham, UK
    Posts
    360
    Think you'd have to create a new table with the char(2) column and then insert using rtrim. Then drop the old table and rename the newly created one e.g.

    SQL> create table t3 (col1 char(4));

    Table created.

    SQL> create table t4 (col1 char(2));

    Table created.

    SQL> insert into t3 values ('AA');

    1 row created.

    SQL> commit;

    Commit complete.

    SQL> insert into t4 (select rtrim(col1,' ') from t3);

    1 row created.

    SQL> commit;

    Commit complete.

    SQL> select * from t4;

    CO
    --
    AA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width