2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ServiceNowでString Typeの文字列長を調べる

Last updated at Posted at 2019-12-10

Version: Newyork

適当に確認

ServiceNowでString Typeで文字列長40のColumnに値を入れます
FireShot Capture 035 - bbb - Table - - ぽんぽこシステム - .service-now.com.png

ServiceNowで文字列長が40の場合40byteではなく40文字として扱われるようです全角は40文字まで入りました半角41文字は入りませんでしたまたUTF-8で4byte必要な文字は扱えないのか文字化けしました
FireShot Capture 036 - bbbs - ぽんぽこシステム - .service-now.com.png

4byte必要な絵文字も化けました
FireShot Capture 037 - bbbs - ぽんぽこシステム - .service-now.com.png

ServiceNowの文字コードはdefaultでutf-8だったと思いますDiagnostics Pageで確認するとDBはMaria5.6.21のようです

Database overview
Type mysql
Version 5.6.21-MariaDB-log
Driver mariadb-jdbc
JDBC 1.1

因みにString Typeの最大文字列長は試したところMySQLのLONGTEXTの最大長(4,294,967,295)の半分の2,147,483,647文字の様です(2,147,483,648に変更しようとするとエラーが出ます)
image.png

Stringで256以上のmax lengthだとDB的にmediumtext型になるらしくて16,777,215 bytesまで入るらしい

あとすっごいびっくりしたのですがStringで256以上のmax lengthだとDB的にmediumtext型になるらしくて16,777,215 bytesまで入るらしいとIncidentのDescriotionとか4,000なので16,777,215 bytes入るはず

[Fields in ServiceNow accept string inputs greater than the sys_dictionary max_length value - Support and Troubleshooting]
https://hi.service-now.com/kb_view.do?sysparm_article=KB0685779

Fields in ServiceNow accept string inputs greater than the sys_dictionary max_length value.
 
This is expected behavior of the product.
 
When you create a string field in ServiceNow, the underlying column in database is created with a default data type based in part on the specified max_length value.
 
Small (40) = varchar(40)
Medium (100) = varchar(100)
Large (1000) = mediumtext
Extra Large (4000) = mediumtext
 
Any string field that is larger than varchar(255) is given the mediumtext data type. In the client, it will be represented as HTML textarea, instead of an HTML input. The maximum length of mediumtext is 16,777,215 bytes.

ServiceNowでLength 40の項目に41文字以上の値でInsertするとエラーも出ずに40文字で切れて挿入される

最初この仕様にびっくりしました このSQLモードが指定されていないんだろうなと想像しています

STRICT_TRANS_TABLES

値を指定したとおりにトランザクションテーブルに挿入できない場合、ステートメントを中止します。 非トランザクションテーブルの場合、値が単一行ステートメントで発生するか、複数行ステートメントの先頭行で発生した場合、ステートメントを中止します。 詳細については、このセクションのあとの方で説明します。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?