Database Views in Reporting
Database Views let you join data from multiple tables into a single read-only virtual table — perfect for reports that need fields from two related tables without complex scripting. Understanding their limits and when to use them is a key exam skill.
What Is a Database View?
A standard ServiceNow report is built on a single table. If you need fields from a related
table (accessed via a Reference field), you can only dot-walk one level — for example,
incident.caller_id.department. But dot-walking has limits, and some report
types don't support it.
A Database View (stored in sys_db_view) solves
this by creating a virtual table that joins two or more tables. The join is defined once,
and then users can report on the view as if it were a flat table with all the columns from both.
Create a Database View
Navigate to: System Definition → Database Views → New
- Set the Name (becomes the view's table name)
- Add the Left Table (the primary table — all its records appear)
- Add Right Tables (joined tables) with join conditions
- Select which columns from each table appear in the view
Join Types
Database Views support two join types. Understanding the difference is critical for predicting which records appear in reports:
| Join Type | Records Included | Use When |
|---|---|---|
| Inner Join | Only records where both tables have a match. A left-table record with no matching right-table record is excluded. | You only care about records that have related data in both tables (e.g., incidents with a user record) |
| Left (Outer) Join | All records from the left table, plus matching records from the right table. Left records with no match show NULL for right-table fields. | You want all records from the primary table, even those without a match (e.g., all incidents, including ones with no assigned user) |
incident to sys_user
on caller_id, and some incidents have no caller_id set, those incidents are excluded
from the Inner Join view. If your report shows fewer incidents than expected, check
whether you need a Left Join instead.
Database View Limitations
Database Views are powerful but have important restrictions that the exam tests:
- Read-only — you cannot insert, update, or delete records through a Database View. They are reporting-only constructs.
- No ACL enforcement on view structure — the join columns are defined statically; you can't have dynamic join conditions per user.
- Performance impact — complex views with many joined tables can slow reports. Each execution re-runs the join query.
- No Script support on view fields — calculated fields or scripted transformations cannot be added at the view level.
- Cannot be used as Import Set targets — since they're read-only virtual tables.
caller_id.department) when it's a one-level
relationship and the report type supports it — no view setup needed.
Database Views for CMDB Reporting
Database Views are especially useful in CMDB reporting where you need to combine CI data with related table data:
- CI + Incidents — join
cmdb_citoincidenton the affected_ci field to report on which CIs generate the most incidents - CI + Change Requests — similar join to show which CIs have the most change activity
- CI + cmdb_rel_ci — join CI to its relationships to report on relationship types per CI class
Note: when joining to cmdb_ci, always add a class filter in the view or the
report — otherwise you join against all CI types and the result set is enormous.
Common Exam Traps — Database Views in Reporting
- Database Views are stored in
sys_db_view— virtual read-only joins of multiple tables - Inner Join = only matching records from both tables; Left Join = all left-table records
- Inner Join excludes left-table records with no match in the right table
- Database Views are read-only — cannot be used for inserts, updates, or import targets
- Use Database Views when dot-walking doesn't cover the join you need, or multiple writers need the same cross-table view
Practice Questions
4 questions · Select an answer to see the explanation immediately.
A report needs to show Incident records alongside the CI class name and support_group of the affected CI, but the CI data is in a separate CMDB table. What is the simplest approach?
B is correct. When a report needs fields from a referenced table that's only one level away (incident.cmdb_ci → cmdb_ci.sys_class_name), dot-walking is simpler and more maintainable than creating a Database View. In the Report Builder, you can select "cmdb_ci.sys_class_name" and "cmdb_ci.support_group" directly as fields, and ServiceNow automatically traverses the reference field. Database Views (A) are needed when dot-walking isn't sufficient — for example, many-to-many joins, left joins showing all records even without a match, or complex multi-table joins that dot-walking can't express.