ArcGIS中的schema

schema指的是数据库的数据结构。对于Geodatabase中的表来说,schema指的是这个表的结构、表名称、字段名称、字段类型等等。对于Geodatabase来说,schema指的是Geodatabase中的表、要素集、要素类、子类和关联类(relationship)等等。

About schema locks

A schema within the geodatabase is the structure or design of a geodatabase or geodatabase object, such as a table, feature class, or attribute domain as opposed to the underlying data. Schema locks are used to manage geodatabase schemas to ensure the structure of a dataset will not change once it has been opened or referenced.

The ISchemaLock interface is used to manage the schema locks associated with a dataset or object. The following are the schema lock types:

Shared schema locks—These are applied automatically by the geodatabase when accessing a dataset and are removed when all references to the dataset are removed. For this reason, it is not necessary to explicitly apply or remove shared schema locks. There is no limit to the number of shared schema locks a dataset or object can have.

Exclusive schema locks—In contrast to shared schema locks, exclusive schema locks are controlled by the developer or ArcGIS application, such as ArcMap or ArcCatalog. An exclusive lock is used to lock a geodatabase dataset or object from use by others to make the necessary changes to it. An exclusive lock is promoted from a shared lock and demoted back to a shared lock when no longer needed. The presence of additional shared schema locks on a dataset or object prevents an exclusive schema lock from being applied and precludes the ability to make changes to the underlying dataset and its schema while it is in use. Only one exclusive schema lock is allowed per dataset. As opposed to shared schema locks, exclusive schema locks are not applied or removed automatically. It is the responsibility of the developer to apply or remove exclusive schema locks.

ISchemaLock    Provides access to members for accessing schema locking functionality.

When To Use Use

ISchemaLock to establish an exclusive lock on a dataset when changing its schema, or performing other operations that require exclusive access to the data.

public void DeleteField(IObjectClass objectClass, String fieldName)
{
    // Get the field to be deleted.
    int fieldIndex = objectClass.FindField(fieldName);
    IField field = objectClass.Fields.get_Field(fieldIndex);

    // Cast to the ISchemaLock interface.
    ISchemaLock schemaLock = (ISchemaLock)objectClass;
    try
    {
        // Get an exclusive schema lock on the object class. 
        schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);

        // Alter the class extension for the class.
        objectClass.DeleteField(field);
    }
    catch (Exception e)
    {
        // An error was raised; therefore, notify the user.
        Console.WriteLine(e.Message);
    }
    finally
    {
        // Since the Finally block is always called, the exclusive lock is demoted
        // to a shared lock after the field is deleted and after an error is raised.
        schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
    }
}

 http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/d/0001000004qw000000.htm

原文地址:https://www.cnblogs.com/5igis/p/5igis_10565.html