oracle database adjustment field type

        The oracle database changes the field type comparison ink, because if the field has a value, it is not allowed to directly change the field type. In addition, Oracle does not support adding a field after a specified field, but MySQL data can add a field after a specified field.

        mysql adds a new field after the specified field :

        alter table exam add add field name add field type after specify field name

If oracle wants to modify the field type, it has to be implemented separately, but the only disadvantage is that the order of the fields has changed.

For example: in the tab_user table addr field type is int, change to varchar2(30)

1. Add a new field, the type is varchar2(30)

     alter table tab_user addr_new varchar(30);

2. Assign the value of the addr field to the new field addr_new

     update tab_user set addr_new=addr;

3. Delete the original field addr

     alter talbe tab_user drop column addr;

4. Rename the new field addr_new to addr

      alter table tab_user rename column addr_new to addr;

Guess you like

Origin blog.csdn.net/dhklsl/article/details/129981881