- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 07:54 PM
Hello. How do I reconstruct the ServiceNow table in a script? After executing the deletion script in the following job schedule I want to add the process of rebuilding the table. Is it possible to optimize table with ServiceNow script?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2022 01:21 AM
Yuki,
Check Mwatkins's reply in the following thread.
The thread is a little bit old but the following statement should still hold true.
Generally ServiceNow does not expose this layer of database administration because we don't want our customers to have to worry about it.
Not sure if the followings still hold but may be worth a try.
If you wanted to force reorganization on a certain table you could create a meaningless, hidden, custom field on that table. Then next time you want to reorganize the table you could remove said field.
Another way to force a table reorganization is to add an index to the table. Each time an index is added we do the same online alter operation that totally re-creates the table.
Following article by ServiceNow suggests using table cleaner. Check warning about performance before using it on production instance.
Following Now Support page has instructions on how to use table cleaner.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0694151
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 08:09 PM
Hi, your script deletes the content of your table - it does not delete the table.
Without details of the source data that will be populated back into the table or the process you will use to load\transform the data I do not think that the forum can provide an answer to your question.
Perhaps you could update this thread with clear and specific details of your requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 08:25 PM
申し訳ありませんが、スクリプトの抜粋を投稿しました。
「output_table_name」テーブルはカスタムテーブルです。
削除されるレコードは、「u_datetime」と呼ばれる日付形式の列によってフィルタリングされます。

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 09:34 PM
Hi,
As you have put log statements, are you getting those logs?
Please share which logs you are getting.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 09:50 PM
I'm sorry, there is no log that can be presented immediately.
Is it difficult to answer without a log?
The point at issue is that fragmentation occurs when the above script deletes a record
in the table, and ServiceNow's capacity is tight.
Therefore, we are considering the rebuilding process other than by requesting
ServiceNow support.