Changing the maximum length of a varchar column?

后端 未结 9 1584
[愿得一人]
[愿得一人] 2021-01-30 12:02

I\'m trying to update the length of a varchar column from 255 characters to 500 without losing the contents. I\'ve dropped and re-created tables before but I\'ve never been expo

相关标签:
9条回答
  • 2021-01-30 12:48

    This worked for me in db2:

    alter table "JOBS"  alter column "JOB_TITLE" set  data type varchar(30);
    
    0 讨论(0)
  • 2021-01-30 12:49
    ALTER TABLE TABLE_NAME MODIFY COLUMN_NAME VARCHAR(40);
    

    Late to the question - but I am using Oracle SQL Developer and @anonymous's answer was the closest but kept receiving syntax errors until I edited the query to this.

    Hope this helps someone

    0 讨论(0)
  • 2021-01-30 12:54

    For MariaDB, use modify column:

    ALTER TABLE table_name MODIFY COLUMN column_name VARCHAR (500);
    

    It will work.

    0 讨论(0)
提交回复
热议问题