Tables in the ServiceNow Database

Casper6060
Mega Sage

Hi everyone

As part of some work i'm doing, i'm trying to understand the ServiceNow database better.

So far i have understood that there of course are base classes which are tables with no parent.

These tables could have none, one or more children.

Then there is a child class which is a child of a parent.

And then there is a parent class which itself is a child of a class, but also has children itself.

There are probably more examples.

 

Then there are some tables that have physical tables, and some do not.

 

For an example task is a physical table, since you can query it in the database with SELECT * FROM task; and get a result. Whereas incident is a logical table since it's part of the task table and can only be found with a where statement on the task table. SELECT * FROM task WHERE sys_class_name = 'incident';

 

I had the assumption that all base tables would always be physical tables, and all child tables would be logical tables, however, this is not true. For an example

 

The table "discovery_credentials" is indeed a base class and has a physical table. But the "windows_credentials" table which extends the "discovery_credentials" thereby being a child table, ALSO has a physical table in the database.

 

So my first question would be, is there any knowing which is which?

 

Because i know that the table sys_db_object contains information about every single table in ServiceNow.

 

However on an ootb vancouver install. I found this table "ecc_agent_privileged_command_m2m" and it is a base class, but has no physical table in the database, so i'm not sure how to even find the data.

1 ACCEPTED SOLUTION

Bert_c1
Kilo Patron

See:

 

TaskTableFlattening.html

 

Enjoy

 

And look in 'sys_storage_alias' for field mapping, and in sys_storage_table_alias for db tables.

View solution in original post

5 REPLIES 5

Sure, use the 'Debug SQL' or 'Debug SQL (Detailed)' module, and query a table for a record.  details are extensive though. You can view the 'sys_class_name' fields on task and cmdb. the cmdb table has the sys_class_path field that shows the hierarchy. Based on the sys_class_code value of the table in sys_db_object.

A convenient GlideRecord API is:

 

https://developer.servicenow.com/dev.do#!/reference/api/xanadu/server_legacy/c_TableUtilsAPI#r_TU-ge...

 

there is the following tables related to table and fields

sys_dictionary
sys_documentation
sys_db_object
sys_custom_db_object

 

See:

https://www.servicenow.com/docs/bundle/xanadu-platform-administration/page/administer/reference-page...

for more info