Make Table View (Data Management)

License Level:BasicStandardAdvanced

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

Syntax

MakeTableView_management (in_table, out_view, {where_clause}, {workspace}, {field_info})
ParameterExplanationData 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

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
5/7/2015