Change the number in Varchar2 Data Type

Hello

We have a running production applications. There is a column called home_number which is a type of data number, now called the new requirement to change of varchar2.

I tried to edit the table get the below error.


-Edit the "TECH_SOURCING_EMPLOYEE_DETAILS" table change
-("HOME_PH_NUMBER" VARCHAR2 (1000))
-- /

-ORA-01439: column to change must be empty to change data type

Please suggest me how to change the data type of column without affecting the data.

Thank you
Sudhir

Try below, I tested in my database.

create table tmp
(ID NUMBER,
 HOME_NUMBER NUMBER(8));

insert into tmp values(1, 9122222);

alter table tmp add MY_HOME_NUMBER VARCHAR2(1000);

update tmp
  set my_home_number = home_number;

update tmp
   set home_number = NULL; 

alter table tmp drop column home_number;   

alter table tmp rename column my_home_number to home_number; 

Tags: Database

Similar Questions

  • for the number and character data type

    Hello
    I want a field to be consist of numeric values and characters.
    Is there any type of data like this in oracle?

    ;)

    SQL> create table vehicles (reg varchar2(10));
    
    Table created.
    
    SQL> insert into vehicles (reg) values ('VIC123');
    
    1 row created.
    
    SQL> insert into vehicles (reg) values ('ABC4566');
    
    1 row created.
    
    SQL> select * from vehicles;
    
    REG
    ----------
    VIC123
    ABC4566
    
    SQL>
    

    I guess that your 1300 odd other messages are not in one of the SQL or PL/SQL Developer type forums then as someone with whom I would expect several posts to know that they can store things in a VARCHAR column?

  • convert the varchar2 data type to the data number type

    How to convert the varchar2 data type to the data type number.


    It looks like my data

    create table one)
    col1 varchar2 (50)
    col2 varchar2 (500);

    Insert in a (col1, col2) values ('1234 ', ' 2345');

    Select Column1 of number (19)) cast (to_number (col1);

    IAM getting error invalid number


    I need to create a table with the same columns with data like number types (19)

    can someone help me

    Thank you

    You have changed your original post, so now I see that you get the invalid number.

    This is why you should always avoid the varchar columns to store numbers or dates...

    Since your table source contains a nonnumeric value, you can write a pl/sql to convert data and see what records are false:

    SQL> insert into a (col1,col2) values ('xxxx','2345');
    
    1 row created.
    
    SQL> select * from a;
    
    COL1     COL2
    -------- --------
    1234     2345
    xxxx     2345
    
    2 rows selected.
    
    SQL> create table b (col1 number(19), col2 number(19));
    
    Table created.
    
    SQL> set serverout on
    
    SQL> declare
      2  cursor c is
      3  select * from a;
      4  begin
      5    for r in c loop
      6     begin
      7       insert into b values (to_number(r.col1), to_number(r.col2));
      8     exception
      9       when invalid_number then
     10        dbms_output.put_line('Row rejected: col1='||r.col1||' col2='||r.col2);
     11     end;
     12    end loop;
     13  end;
     14  /
    Row rejected: col1=xxxx col2=2345
    
    PL/SQL procedure successfully completed.
    
    SQL> select * from b;
    
          COL1       COL2
    ---------- ----------
          1234       2345
    
    1 row selected.
    

    Max

    Published by: Massimo Ruocchio, June 14, 2011 20:00
    Added the first query in the example

  • How can I justify the difference between varchar and varchar2 data type

    Hi all

    How can I justify the difference between the data type varchar and varchar2 on any table for space management.
    Is there any query to justify this.


    Concerning
    Girish

    Published by: boujemaa on February 2, 2011 21:23

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14220/datatype.htm#sthref3780


    The VARCHAR data type

    The VARCHAR data type is synonymous with the VARCHAR2 data type. To avoid any changes in behavior, always use the VARCHAR2 data type to store strings of variable length.

  • NVL function varies from char to varchar2 data type

    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0  Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    
    SQL> create table fullJoinTest1(col1 char(14));
    
    Table created.
    
    SQL> create table fullJoinTest2(col1 char(14));
    
    Table created.
    
    SQL> insert all
      2  into fullJoinTest1 values('aaa')
      3  into fullJoinTest1 values('bbb')
      4  into fullJoinTest2 values('aaa')
      5  into fullJoinTest2 values('ccc')
      6  select 1 from dual;
    
    4 rows created.
    
    SQL> select nvl(a.col1,b.col1) as aaaa
      2    from fullJoinTest1 a full join fullJoinTest2 b
      3      on a.col1=b.col1
      4   where nvl(a.col1,b.col1)= 'ccc';
    
    no rows selected
    
    SQL> create table fullJoinTest3 as
      2  select nvl(a.col1,b.col1) as "WhatIsType?"
      3    from fullJoinTest1 a full join fullJoinTest2 b
      4      on a.col1=b.col1
      5   where nvl(a.col1,b.col1)= 'ccc';
    
    Table created.
    
    SQL> desc fullJoinTest3
     Name          Null?    Type
     ------------- -------- ------------
     WhatIsType?            VARCHAR2(14)
    
    SQL> create table fullJoinTest4 as
      2  select case when a.col1 is not null then a.col1 else b.col1 end as "WhatIsType?"
      3    from fullJoinTest1 a full join fullJoinTest2 b
      4      on a.col1=b.col1;
    
    Table created.
    
    SQL> desc fullJoinTest4
     Name        Null?    Type
     ----------- -------- --------
     WhatIsType?          CHAR(14)
    My question is why nvl function varies from char to varchar2 data type?
    Same case expression does not change the data type.
    I insist that this is a bug of function nvl isn't - it.

    Documented behavior:
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions119.htm#SQLRF00684

    If expr1 is character data, then Oracle Database converts expr2 to the data type of expr1
    before comparing them and returns VARCHAR2 in the character set of expr1.
    
  • Convert a varchar2 data type Date

    Hi guys,.

    Can someone help me convert a Varchar2 data type in the data type Date?

    I have a query and my column is a varchar2 data type.
    I want to just that convert the Varchar2 in a DATE, because I met
    problem in my query. I want to do the day1 day10 transaction.

    Ex:
    Day 1 = January 1, 2010
    Day10 = January 10, 2010

    table.record_date varchar2 (12)

    SELECT column1, Column2
    table
    where record_date between? and?

    How can I set the record_date between day1 and day10 since record_date is of type varchar?

    Thank you.

    Laetitia

    Lala,

    If the data in the database are in the format MM-DD-RR , then you must use the same format when you convert back to this day.

    So change the query to

    SELECT COLUMN1, COLUMN2 FROM TABLE WHERE TO_DATE(RECORD_DATE, 'MM-DD-RR') BETWEEN TO_DATE('01-JAN-2010') AND TO_DATE('10-JAN-2010')
    

    Kind regards

    Manu.

  • Change the setting from VarChar2 to the CLOB

    Hello

    I have a csvToArray function which takes a csv string and converts it to an array.

    PROCEDURE csvToArray (p_csvString IN VarChar2,
    p_count ON PLS_INTEGER,
    p_array OUT ARRAY_T) IS...

    Unfortunately, the size of the csvString passed in exceeds 32K, so I thought to change the csvString from Varchar2 to CLOB type, i.e.

    PROCEDURE csvToArray (p_csvString IN CLOB,
    p_count ON PLS_INTEGER,
    p_array OUT ARRAY_T) IS...

    The procedure uses only the string substr and instr functions to search for items in the csv string to put in a table.

    I tested the change and it works, but I should consider with the change to the data type, or will that always precedes work properly? Extreme max of p_csvString size would be around 150 K.

    Version of database is 10.2.0.4.0


    Thank you

    Since you're on 10.2, SUBSTR and INSTR functions were overcrowded to handle the CLOB, then you should be fine.

    Justin

  • How to change the number of items in number to Boolean, function VI table

    Hi, I'm working on using the digital output of data acquisition to control the digital input of a DAC, and I used the Number function in Boolean table. VI to convert the number to a Boolean array. The maximum number is 4096, so it must be composed of 12 elements.

    For the description of the VI, it is said that Boolean matrix returns a table of 8, 16, 32 or 64 elements, according to the number of bytes in the whole. Therefore, I change the number of channels in the task to 16, but it still does not work. The suggesitions are greatly appreciated.

    Thank you!

    Possible reasons:

    Scripture cannot be performed because the number of data channels does not match number of channels in the task.

    When writing, provide data for all channels in the task. You can also change the task so that it contains the same number of channels as the written data.

    Number of job channels: 12
    Number of data channels : 32

    Task name: _unnamedTask<1B>

    Once you have the array of Boolean, you can resize using table tools. For example you can use the "new range" with a length of 12 to pad the table of 12 elements of Boolean values (you can also use a subset of table).

  • How to change the number of values in the hour that are restricted.

    Hello

    May I know how to change the number of values in the hour that are restricted.

    In fact, we have improved of obiee in obiee 11g 10g. Data base is the same for Both.In 10 g the prompt value is limited to show only 35 records per page. As we passed it shows only 35 Records in 11g also. How can I change this limit to 11g.

    Please suggest me! Its urgent!

    Thanks and greetings

    Navnitha

    Hello

    In the advance tab we have the XML of the upgraded report, copy it into a Notepad and try to find the line beginning as below

    In 10g, we have something like below, simply remove the choicesPerPage = '35' from 11 g OBIEE XML report

    Thank you

    RAM

  • VARCHAR2 data type do not convert date

    Dear gurus

    Version of database - 10.2.0

    I have a problem of varchar2 data type do not convert date...

    I have a table like


    SQL > table desc.
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    NAME VARCHAR2 (10)
    RECORD_DATE VARCHAR2 (20)

    and the record consists are...

    SQL > select * from table;

    NAME RECORD_DATE
    ---------- --------------------
    Nimai 09/09/2012 09:10
    Nimai 09/09/2012 10:10
    Scott 09/09/2012 11:10
    Scott 09/10/2012 10:00
    Nimai 09/10/2012 11:00


    If the "Record_date" column that's 09/09/2012(dd/mm/yyyy)

    09/09/2012 and I want to query the records which includes the date ' select * from table where record_date = 09/09/2012 "...
    This work of query...

    Select * from table where
    TO_CHAR (to_date (substr(record_date,1,10), ' dd/mm/yyyy'), ' dd/mm/yyyy')
    =
    TO_CHAR (to_date (substr('09/09/2012',1,10), ' dd/mm/yyyy'), ' dd/mm/yyyy')
    ;

    But if the "record_date" column that's 9/9/2012(d/m/yyyy) I did not what to do which function to use? /

    Help, please!

    Thanks in advance
    Nimai kinzonzi

    Published by: 955748 on September 22, 2012 03:47

    Published by: 955748 on September 22, 2012 04:10

    Hello;

    Keep things simple: (get rid of TO_CHAR)

    SELECT TO_DATE ((substr (record_date, 1, 10), ' DD/MM/YYYY') of?)

    TO_DATE (substr (record_date, 1, 12), "HH24 MON-DD-YY")

    Best regards

    mseberg

  • Change the format of a date field to be used in a file name.

    Good afternoon!

    I use Livecycle ES3 and Adobe Professional XI

    I have a form in livecycle for employee evaluations.

    I'm saving a file based on domain names.  My problem is when I use a date in my file name field.  I have the scripts to work for the confidence function and the button on the form field.  They are listed below.

    Script folder level-

    mySaveAs = app.trustPropagatorFunction (function (doc, path)
    {
    app.beginPriv ();
    doc.saveAs (path);
    app.endPriv ();
    });

    myTrustedSpecialTaskFunc = app.trustedFunction (function (doc, file_path)
    {
    Privileged and non-privileged code above
    app.beginPriv ();
    mySaveAs (doc, file_path);
    app.endPriv ();
    });

    Button script

    () myTrustedSpecialTaskFunc

    this, "/ c/myfiles / ' + ReviewPeriodTo.rawValue + '-' + Div.rawValue + '-' + EVALTTYPE.rawValue + '-' + LASTNAME.rawValue + '-' + FIRSTNAME.rawValue +

    ".pdf");

    My problem is the ReviewPeriodTo.rawValue.  When I enter data in the form and that you do not enter a value for the ReviewPeriodTo field, the file is saved with the values of other fields, and a null value is inserted where the field would go to date.

    When I type a value such as 2014-03-15 in the area of the ReviewPeriodTo and values in other areas, it works.

    When I try to insert a value in as the 15/03/2014 in the area of the ReviewPeriodTo, I get the following error.

    RaiseError: The file may be read-only or another user can open. Please save the document under a different name or in a different folder.

    Doc.saveAs:16:XFA:form1 [0]: page 1 [0]: #subform [0]: Button3 [0]: mouseUp

    = > The file may be read-only or another user may be subject to open. Please save the document under a different name or in a different folder.

    My problem is, it's part of a much larger process when I import information from a make table query MS Access which is exported to Excel.  If I could just format field data automatically to formation of yyyy-mm-dd since t, that would work, but I don't know how to do coding in MS Access.

    Question: How can I format the data which are entered on the form to be the yyyy-mm-dd format?

    I tried to change the display format and data through models livecycle for the field, but it does not work.

    Any help would be greatly appreciated!

    Thank you

    Hello

    It sounds like you need to specify all the formats users can enter the date in the editing modes.  If it matches one of the formats then the rawValue will be automatically formatted to yyyy-mm-dd format.

    This means that if the formattedValue is equal to the rawValue then the date does not match one of the edition models so you will need display an error message.

    Concerning

    Bruce

  • Setting to change the number of days to sync e-mail

    Where the parameter move to if you want to change the number of days that will be synchronized to your e-mail accounts? Or he is let out iOS 10 for some reason any?

    vrmcw wrote:

    Where the parameter move to if you want to change the number of days that will be synchronized to your e-mail accounts? Or he is let out iOS 10 for some reason any?

    account settings - sync mails - 'Exchange' on my phone - spam day-

    Not an ios 10 issue that I don't have the function to my yahoo account.

    Maybe you should ask your email provider.

  • How to change the number of minutes for the exercise of the activity of the application

    How to change the number of minutes for the exercise of the activity of the application

    Hello

    It is not currently possible to change the goal of daily exercise.

    If you want to suggest that Apple consider adding this option, you can submit a request here:

    https://www.Apple.com/feedback/watch.html

  • Cannot change the number of laptop Apple ID because I moved from the India

    I can't change the number of mobile for notifications in my Apple/iCloud account, it shows my old Indian number but I moved from the India and now Iam in Tanzania. He asked security questions that I don't even remember...

    I can not yet implemented iCloud keychain...

    Need help, he cannot set up on my Mac, the iPhone or iPad

    You can change preferences/iCloud/Keychain/options of the system?

  • How to change the number of tabs pinned when I open a new tab?

    Before today, I have easy access to 8 tabs pinned on my page tab and now I have only 4 and I can't change it back. What was changed and how can I change the number of pinned tabs?

    "What was changed and how can I change the number of pinned tabs?"

    The css for the margins and tiles has been changed. Try Zoom Out = {Ctrl liked-} to see more tiles. I need zoom back twice to get a 2nd rank.

    Or use this extension - https://addons.mozilla.org/en-US/firefox/addon/new-tab-tools/ - for more control on what is and what is not displayed on the new tab page.

Maybe you are looking for

  • Change the cover Photo in the Photo Albums

    Hello... My message all in the apple community. New amounted to apple, and my first purchase is an iPhone 7. Loving the camera and he can do with photos. How can I change the picture of an album cover that I created...? I've read a lot online, but al

  • Noisy fan - fan starts 15 minutes after turning on the Qosmio F10

    My Qosmio F10 has always had a very noisy fan. The fan noise starts always 15 minutes after turning the PC on and stays of less regardless of what I do on the PC - even if this happens be nothing else! I tried to change the battary cooling method opt

  • HP Scan quit unexpectedly on Mac OSC 10.8.2 with HP CM2320nf MFP

    I can print but can't scan using the HP CM2320nf MFP and my Mac Book Pro.  I get 'Scan HP close unexpectedly'.  I have reset printer in the OS.  I uninstalled and reinstalled the latest drivers.  The problem persisiting.  I can't find anything on the

  • How to manage data in an array of Boolean

    Hello I have Boolean values inside the table 1 d and I have a numerc control and a text file so that the entrynumber will be compared to the number in the text fileIf the numbers match, the Boolean value of this number goes onThe issue is that when I

  • you backup using drive e.

    Can I save everything using the E drive?