Remove Join (Data Management)

Summary

Removes a join from a feature layer or table view.

Usage

  • The Join parameter is the name of the table that was joined to the input layer or table view.

    • If the join table was a dBASE file named MyTable.dbf, the join name would be "MyTable"; so to remove it, specify "MyTable".
    • If the join table was an INFO or Geodatabase Table named MyTable2, the Join Name would be "MyTable2"; so to remove it, specify "MyTable2".
    • The join name will not reflect the name of the table view itself, but rather the source of the table view. Therefore, if a table view is named TableView1 and points at mytable.dbf, the name of the join will be "mytable".

  • When a layer is joined to two tables and the first join is removed, then both joins will be removed. For example, Layer1 is joined to TableA. Then Layer1 is joined to TableB. If the join to TableA is removed, the join to TableB is also removed.

  • In ModelBuilder, you can use the Make Feature Layer tool to make a layer from a feature class, and the Make Table View tool to create a table view from an input table or feature class. These layers or table views can then be used as the input to the Add Join and Remove Join tools.

Parameters

LabelExplanationData Type
Layer Name or Table View

The layer or table view from which the join will be removed.

Mosaic Layer; Raster Layer; Table View
Join
(Optional)

The join to be removed.

String

Derived Output

LabelExplanationData Type
Layer With Join Removed

The updated input dataset.

Table View; Raster Layer; Mosaic Layer

arcpy.management.RemoveJoin(in_layer_or_view, {join_name})
NameExplanationData Type
in_layer_or_view

The layer or table view from which the join will be removed.

Mosaic Layer; Raster Layer; Table View
join_name
(Optional)

The join to be removed.

String

Derived Output

NameExplanationData Type
out_layer_or_view

The updated input dataset.

Table View; Raster Layer; Mosaic Layer

Code sample

RemoveJoin example 1 (Python window)

The following Python window script demonstrates how to use the RemoveJoin tool in immediate mode on a feature layer in the TOC named veglayer.

import arcpy
arcpy.RemoveJoin_management("veglayer", "vegtable")
RemoveJoin example 2 (stand-alone script)

This stand-alone script shows the RemoveJoin function as part of a workflow to add a field to a table and calculate its values based on the values in a field from a joined table.

# AddFieldFromJoin.py
# Description: Adds a field to a table, and calculates its values based
#              on the values in a field from a joined table

# Import system modules
import arcpy

# set the environments
arcpy.env.workspace = "C:/data"
arcpy.env.qualifiedFieldNames = "UNQUALIFIED"
    
# Define script parameters    
inFeatures = "Habitat_Analysis.gdb/vegtype"
layerName = "veg_layer"
newField = "description"
joinTable = "vegtable.dbf"
joinField = "HOLLAND95"
calcExpression = "!vegtable.VEG_TYPE!"
outFeature = "Habitat_Analysis.gdb/vegjoin335"
    
# Add the new field
arcpy.AddField_management (inFeatures, newField, "TEXT")
    
# Create a feature layer from the vegtype featureclass
arcpy.MakeFeatureLayer_management (inFeatures,  layerName)
    
# Join the feature layer to a table
arcpy.AddJoin_management (layerName, joinField, joinTable, joinField)
    
# Populate the newly created field with values from the joined table
arcpy.CalculateField_management (layerName, newField, calcExpression, "PYTHON")
    
# Remove the join
arcpy.RemoveJoin_management (layerName, "vegtable")
    
# Copy the layer to a new permanent feature class
arcpy.CopyFeatures_management (layerName, outFeature)

Environments

This tool does not use any geoprocessing environments.