Column table String type max length

christiandeange
Tera Contributor

Hi all,

I have a question about the max length of column of type string.

I created a new column and set the max length to 5000 but once I go to the form I can paste a string of 20000 character in the field. I save the record and the value doesn't trunc or modified.

The max length seems bugged or it is illimitate.

Can you explain me if it is normal and if does exist a real max length? I'm on an Helsinki instance.

Thanks.

Best Regards.

8 REPLIES 8

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

Christian,



The field is actually created on database level as 'mediumtext' and the restriction is usually done from application side. FYI:



MEDIUMTEXT [CHARACTER SET charset_name] [COLLATE collation_name]


A TEXT column with a maximum length of 16,777,215 (224 − 1) characters. The effective maximum length is less if the value contains multibyte characters. EachMEDIUMTEXT value is stored using a 3-byte length prefix that indicates the number of bytes in the value.



MySQL :: MySQL 5.7 Reference Manual :: 11.1.3 String Type Overview


Hi Sergiu,



Can you confirm the following list?


  • TINYTEXT   256 bytes
  • TEXT                     65,535 bytes   ~   64kb
  • MEDIUMTEXT     16,777,215 bytes   ~   16MB --> so this is the maximux size for a string type?
  • LONGTEXT   4,294,967,295 bytes   ~   4GB



Best Regards


We don't really use all those text types. We use varchar up to 255 and then above that usually mediumtext. So maximum size for a string depends on that.


Dear Sergiu

When does Service Now issue an ALTER TABLE?

We experience the issue that if the Size previously was 40 and then increase to 500, truncation to 40 occurs.

I would have tought that the change of the length causes the system to issue an ALTER TABLE to change to MEDIUMTEXT as you indicated.

 

Thanks a lot & Best
Daniel


If this answer was helpful, I would appreciate if you marked it as such - thanks!

Best
Daniel