1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

changing data type from integer to number

Discussion in 'SQL PL/SQL' started by monkey, Jun 9, 2014.

  1. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Hello!
    Please, how would I change data type integer to number in the whole column?
    Using to_number?
    Many thanks!!!
     
  2. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    Hi.

    http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements001.htm#SQLRF00222


     
  3. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Code (SQL):
    SELECT id_p, z, SELECT(to_number(3,0)(z) FROM p)
    FROM p;
    Pkease, ora 00907???
    many thanks!!!
     
  4. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    1) That is (z) ?

    2) to_number(3,0) - this error

    What do you try to write?
     
    monkey likes this.
  5. rajenb

    rajenb Forum Expert

    Messages:
    361
    Likes Received:
    114
    Trophy Points:
    655
    Location:
    Mauritius
    If you are trying to change the datatype of the database column then you need to ALTER the table:

    Code (SQL):
    CREATE TABLE t (
    z INTEGER
    );

    TABLE created.

    SQL> DESC t
     Name                                      NULL?    TYPE
     ----------------------------------------- -------- ----------------------------
     Z                                                  NUMBER(38)

    SQL> ALTER TABLE t MODIFY z NUMBER(3,0);

    TABLE altered.

    SQL> DESC t
     Name                                      NULL?    TYPE
     ----------------------------------------- -------- ----------------------------
     Z                                                  NUMBER(3)