How to create an object class within a geodatabase


Summary
This article shows how to create a table in a geodatabase. The table created with this method is an object class, meaning that it is registered with the geodatabase and has all the associated behavior of an object class.

In this topic


Creating an object class within a geodatabase

The CreateTable method can be used to create a new table or object class in the geodatabase. Tables only exist at the workspace level and are not contained in feature datasets.
 
The use of the IObjectClassDescription.RequiredFields property is recommended when creating a new object class, since it returns the minimum set of fields required for feature class creation. If the RequiredFields property is not used to create the set of fields, it is the responsibility of the developer to create an ObjectID field type. To add more fields to a new or existing object class, see How to create new fields.
CLSID and EXTCLSID
The optional class identifier (CLSID) and extension class identifier (EXTCLSID) parameters allow the calling application to specify the globally unique identifiers (GUIDs) for the objects that implement the instance and the class extension behavior for an object class. 
If using the IObjectClassDescription interface, the InstanceCLSID and ClassExtensionCLSID properties can be used to specify the appropriate CLSID of the object class component object model (COM) class. Supplying the object class CLSID allows the table to take advantage of geodatabase behavior such as aliases, subtypes, and so on.
If no CLSID is passed in, the resulting table is not created as an object class and is not registered with the geodatabase (it will have an ObjectClassID of –1). Valid values for CLSID are esriGeoDatabase.Object or any nonspatial object that aggregates esriGeoDatabase.Object.
The CLSID value must be set if EXTCLSID is set.
Configuration keyword
The optional configurationKeyword parameter allows the application to control the physical layout for this table in the underlying relational database management system (RDBMS) or file geodatabase—for example, in the case of an Oracle database, the configuration keyword controls the table space where the table is created, the initial and next extents, and other properties. 
The configurationKeywords for an ArcSDE instance are set up by the ArcSDE data administrator. The list of available keywords supported by a workspace can be obtained using the IWorkspaceConfiguration interface. For more information on configuration keywords, refer to the ArcSDE documentation. 
The configuration keywords for a file geodatabase are predefined. In most cases, you will use the Defaults keyword. See the following code example:
[Java]
static IObjectClass createObjectClass(IWorkspace2 workspace, String
    nameOfObjectClass, IFields fields, String configKeyword)throws Exception{
    IFeatureWorkspace featureWorkspace = new IFeatureWorkspaceProxy(workspace);

    if (workspace.isNameExists(esriDatasetType.esriDTTable, nameOfObjectClass)){

        // If table with that name already exists, return that table. 
        return new IObjectClassProxy(featureWorkspace.openTable(nameOfObjectClass));

    }

    //     Create an object class description to use if needed for fields collection and for the CLSID parameter.
    IObjectClassDescription ocDesc = new ObjectClassDescription();

    //     If no field collection is supplied, create one using the IObjectClassDescription.
    if (fields == null){

        //Get the set of required fields collection.
        fields = ocDesc.getRequiredFields();

    }

    return new IObjectClassProxy(featureWorkspace.createTable(nameOfObjectClass,
        fields, ocDesc.getInstanceCLSID(), ocDesc.getClassExtensionCLSID(),
        configKeyword));

}


See Also:

How to create new fields
How to create a feature class in a geodatabase
How to create a feature class within a feature dataset




Development licensingDeployment licensing
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine: Geodatabase Update