Summary
Creates a table view from an input table or feature class. The table view that is created by the tool is temporary and will not persist after the session ends unless the document is saved.
Usage
This tool is commonly used to create a table view with a selected set of attributes or fields.
ArcCatalog does not display these table views, but they can be used as inputs to other geoprocessing tools in the current ArcGIS session. Once the ArcGIS application is exited, the table views are deleted.
Table views created in ArcCatalog cannot be used in ArcMap.
If an SQL expression is used but returns nothing, the output will be empty.
Field names can be given a new name by using the Field Info control. The second column on the control lists the existing field names from the input. To rename a field, click the field name and type in a new one.
New field names defined in the Field Info control will be honored in subsequent tools. However, if this tool is the last tool in a model, the field names will be obtained from the source data on disk. To maintain new field names, the new layer has to be written out to a new data using Copy Rows or Copy Features tools.
The field names will be validated by specifying an input workspace. Thus, if the input is a geodatabase feature class, and the output workspace is a folder, the field names may be truncated, since shapefile attributes can only have names of ten characters or less. The new names may be reviewed and altered using the Field Info control.
A subset of fields can be made unavailable in the new layer by using the Field Info control's visible property. The third column in the control provides a dropdown option to specify whether a field will be visible or hidden in the new layer. The default is TRUE. Selecting FALSE will hide that field. You cannot use the hidden fields in a workflow if the newly created layer is input to a subsequent process or tool. If the output is saved to disk, only the fields listed as visible will appear in the new data.
The split policy option on the Field Info control does not apply to this tool.
Syntax
MakeTableView_management (in_table, out_view, {where_clause}, {workspace}, {field_info})
Parameter | Explanation | Data Type |
in_table | The input table or feature class. | Table View;Raster Layer |
out_view | The name of the table view to be created. | Table View ;Raster Layer |
where_clause (Optional) | An SQL expression used to select a subset of features. For more information on SQL syntax see the help topic SQL reference for query expressions used in ArcGIS. | SQL Expression |
workspace (Optional) | The input workspace used to validate the field names. If the input is a geodatabase table and the output workspace is a dBASE table, the field names may be truncated, since dBASE fields can only have names of ten characters or less. The new names may be reviewed and altered using the field information control. | Workspace |
field_info (Optional) | Specifies which fields from the input table to rename and make visible in the output table view. | Field Info |
Code sample
MakeTableView example 1 (Python window)
The following Python window script demonstrates how to use the MakeTableView function in immediate mode.
import arcpy
arcpy.MakeTableView_management("C:/data/input/crimefrequency.dbf", "crimefreq_tview")
MakeTableView example 2 (stand-alone script)
The following stand-alone script demonstrates how to use MakeTableView with a FieldInfo object to filter fields in the output.
# Name: MakeTableView_Example2.py
# Description: Uses a FieldInfo object to select a subset of fields and renaming one field's name.
# Import system modules
import arcpy
# Set data path
intable = "C:/data/tables.gdb/crimefreq"
# Get the fields from the input
fields= arcpy.ListFields(intable)
# Create a fieldinfo object
fieldinfo = arcpy.FieldInfo()
# Iterate through the fields and set them to fieldinfo
for field in fields:
if field.name == "FREQUENCY":
fieldinfo.addField(field.name, "NEWFREQ", "VISIBLE", "")
elif field.name == "CRIME_CAT":
fieldinfo.addField(field.name, field.name, "HIDDEN", "")
elif field.name == "BEAT":
fieldinfo.addField(field.name, field.name, "VISIBLE", "")
# The created crime_view layer will have fields as set in fieldinfo object
arcpy.MakeTableView_management(intable, "crime_view", "", "", fieldinfo)
# To persist the layer on disk make a copy of the view
arcpy.CopyRows_management("crime_view", "C:/temp/newfreq.dbf")
Environments
Licensing information
- ArcGIS Desktop Basic: Yes
- ArcGIS Desktop Standard: Yes
- ArcGIS Desktop Advanced: Yes