A schema is the structure or design of a database or database object such as a feature class or table. A schema lock means that another application is accessing a database, and you are not allowed to alter its structure by adding or removing fields. The most common cause for a schema lock is displaying a dataset in ArcMap.
There are four rules that summarize the behavior of geoprocessing tools and scripts when using data that may also be accessed simultaneously by other applications.
- Tools can always create new data in an output workspace even if the output workspace has a schema lock. An example of this is creating a feature class in a feature dataset using the Create Feature Class tool in ArcCatalog while ArcMap is accessing the feature dataset.
- Tools that update the schema of a dataset will always honor locks applied by other ArcGIS applications that are accessing the dataset. For example, if a roads feature class is being displayed in one ArcMap session, the Add Field tool will fail when it is executed from another ArcMap session using the same roads feature class as input. The tool will fail with a resulting error message, indicating another user is accessing the data.
- Scripts may always update the schema of data created by tools within the same script, even if the current workspace is being used by another application. For example, a script tool may create a feature class in a personal geodatabase that is being accessed by its calling application, such as ArcMap. Typically, personal geodatabases don't allow schema changes to any dataset by another process once it is opened, but the script tool will be able to make a schema change to the feature class it just created.
- Scripts and script tools cannot modify the schema of data being accessed by another application or script. This includes data passed from an application, such as ArcMap, to a script tool, so a script tool can't add or delete a field from a layer passed to it as a parameter.