Label | Explanation | Data Type |
Input Table | The input table or feature class. | Table View; Raster Layer |
Table Name | The name of the table view to be created. | Table View; Raster Layer |
Expression (Optional) |
An SQL expression used to select a subset of records. | SQL Expression |
Output Workspace (Optional) | This parameter is not used. | Workspace |
Field Info (Optional) | The fields from the input table that will be included in the output layer. You can remove input fields by setting them to not visible. Renaming fields and the use of split policies are not supported. | Field Info |
Summary
Creates a table view from an input table or feature class. The table view that is created 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 based on a SQL expression with a selected set of attribute fields.
If an SQL expression is used but returns nothing, the output will be empty.
Parameters
arcpy.management.MakeTableView(in_table, out_view, {where_clause}, {workspace}, {field_info})
Name | 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) | This parameter is not used. | Workspace |
field_info (Optional) | The fields from the input table that will be included in the output layer. You can remove input fields by setting them to not visible. Renaming fields and the use of split policies are not supported. | Field Info |
Code sample
The following Python window script demonstrates how to use the MakeTableView function in immediate mode.
import arcpy
arcpy.management.MakeTableView("C:/data/input/crimefrequency.dbf", "crimefreq_tview")
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 use with MakeTableView
# 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 input fields and add them to fieldinfo
for field in fields:
if field.name == "CRIME_ADDRESS":
# Make the CRIME_ADDRESS field hidden
fieldinfo.addField(field.name, field.name, "HIDDEN", "")
else:
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)
# Persist the view to a table
arcpy.CopyRows_management("crime_view", "C:/data/tables.gdb/crime_copy")