Announcement

Collapse
No announcement yet.

How to change the column type ID from varchar to int?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to change the column type ID from varchar to int?

    Hello.

    Can u help me with subj?

    I broke my head trying to understand it UPSers Or can there be options how to make that the ID consisted only of numbers? Its needed for some applications.

    Thanks in advance.
    Last edited by Frank586; 05-04-2020, 09:29 AM.

  • #2
    Never tried this before, I assume it involve going into myPHPAdmin and changing the field type, the issue here is you are going to crash your system.

    Method 1) Personally I would recommend the Export and Import move (if you have many data and no "unique" field it may be troublesome). Create a new Int Field, export existing data & varchar field. Import the varchar as int.

    Method 2) Alternatively if you want to risk it, check all your field to see if it has a letter, edit them first. Then go into myPHPadmin and make the edit. See how it goes (best to do this with a backup or testing server).

    Here is a more detail guide: https://dev.mysql.com/doc/refman/8.0...ter-table.html
    I want to change the data type of multiple columns from float to int. What is the simplest way to do this? There is no data to worry about, yet.


    I believe this would be the code if you want to edit one of your "account" and want to change the website from varchar to int.

    Code:
     
     ALTER TABLE account MODIFY website INTEGER;
    Sample example
    Code:
     
     ALTER TABLE tablename MODIFY columnname INTEGER;

    Comment


    • #3
      I don't think that is a good idea to change the column id field type.

      Espo uses an algorithm to generate random strings used as record id and you would essentially break that and the indexing required by the system.

      If you need to have a numeric index for a table, I suggest that you create instead a custom field type integer (if you are going to import or create the column values) or auto-increment (if you want the system to create the value for you) and call it numeric_id or something like that so you use that column for your needs.
      Last edited by telecastg; 05-04-2020, 07:17 PM.

      Comment


      • #4
        what about having additional field named "custom_id" from type autoincrement, may helps
        CEO of Eblasoft
        EspoCRM Expert since 2014
        Full Stack Web Developer since 2008
        Creator of Numerous Successful Extensions & Projects​

        Comment

        Working...
        X