ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / SchemaBuilder Class / Create Method / Create(TableDescription) Method
Indicates the ArcGIS.Core.Data.Table to be created.
Example

In This Topic
    Create(TableDescription) Method
    In This Topic
    Enqueue the create operation on the object referred to by the TableDescription.
    Syntax
    Public Overloads Function Create( _
       ByVal tableDescription As TableDescription _
    ) As TableToken

    Parameters

    tableDescription
    Indicates the ArcGIS.Core.Data.Table to be created.

    Return Value

    The TableToken for the ArcGIS.Core.Data.Table to be created.
    Exceptions
    ExceptionDescription
    The total path length for the ArcGIS.Core.Data.Table to be created must be less than 252 characters.
    tableDescription is null.
    Example
    Creating a Table
    public void CreateTableSnippet(Geodatabase geodatabase, CodedValueDomain inspectionResultsDomain)
    {
      // Create a PoleInspection table with the following fields
      //  GlobalID
      //  ObjectID
      //  InspectionDate (date)
      //  InspectionResults (pre-existing InspectionResults coded value domain)
      //  InspectionNotes (string)
    
      // This static helper routine creates a FieldDescription for a GlobalID field with default values
      FieldDescription globalIDFieldDescription = FieldDescription.CreateGlobalIDField();
    
      // This static helper routine creates a FieldDescription for an ObjectID field with default values
      FieldDescription objectIDFieldDescription = FieldDescription.CreateObjectIDField();
    
      // Create a FieldDescription for the InspectionDate field
      FieldDescription inspectionDateFieldDescription = new FieldDescription("InspectionDate", FieldType.Date)
      {
        AliasName = "Inspection Date"
      };
    
      // This static helper routine creates a FieldDescription for a Domain field (from a pre-existing domain)
      FieldDescription inspectionResultsFieldDescription = FieldDescription.CreateDomainField("InspectionResults", new CodedValueDomainDescription(inspectionResultsDomain));
      inspectionResultsFieldDescription.AliasName = "Inspection Results";
    
      // This static helper routine creates a FieldDescription for a string field
      FieldDescription inspectionNotesFieldDescription = FieldDescription.CreateStringField("InspectionNotes", 512);
      inspectionNotesFieldDescription.AliasName = "Inspection Notes";
    
      // Assemble a list of all of our field descriptions
      List<FieldDescription> fieldDescriptions = new List<FieldDescription>()
        { globalIDFieldDescription, objectIDFieldDescription, inspectionDateFieldDescription, inspectionResultsFieldDescription, inspectionNotesFieldDescription };
    
      // Create a TableDescription object to describe the table to create
      TableDescription tableDescription = new TableDescription("PoleInspection", fieldDescriptions);
    
      // Create a SchemaBuilder object
      SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
      // Add the creation of PoleInspection to our list of DDL tasks
      schemaBuilder.Create(tableDescription);
    
      // Execute the DDL
      bool success = schemaBuilder.Build();
    
      // Inspect error messages
      if (!success)
      {
        IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages;
        //etc.
      }
    }
    Creating table with subtypes
    public void CreateTableWithSubtypes(SchemaBuilder schemaBuilder)
    {
      // Creating a 'Building' table with the subtype field 'BuildingType'
      FieldDescription buildingType = new FieldDescription("BuildingType", FieldType.Integer);
      FieldDescription buildingName = new FieldDescription("Name", FieldType.String);
    
      TableDescription tableDescription = new TableDescription("Building", new List<FieldDescription> { buildingName, buildingType });
    
      // Add the building type subtype with three subtypes - Business, Marketing, Security
      tableDescription.SubtypeFieldDescription = new SubtypeFieldDescription(buildingType.Name, new Dictionary<int, string> { { 1, "Business" }, { 2, "Marketing" }, { 3, "Security" } })
      {
        DefaultSubtypeCode = 3 // Assigning 'Security' building type as the default subtype
      };
    
      schemaBuilder.Create(tableDescription);
      schemaBuilder.Build();
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also