> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Get table details

> Retrieve details about a table.



## OpenAPI

````yaml /openapi/cluster-api-v2.json get /databases/{database}/tables/{table}/
openapi: 3.0.0
info:
  description: >-
    REST API for querying information about CockroachDB cluster health, nodes,
    ranges,

    sessions, and other meta information. For additional details, see
    cockroachlabs.com/docs/stable/cluster-api.
  title: CockroachDB v2 API
  license:
    name: Business Source License
  version: '2.0'
  x-logo:
    url: https://www.cockroachlabs.com/docs/images/cockroachlabs-logo-170.png
    backgroundColor: '#FFFFFF'
    altText: Cockroach Labs logo
servers:
  - url: https://localhost/api/v2
  - url: http://localhost/api/v2
security: []
paths:
  /databases/{database}/tables/{table}/:
    get:
      summary: Get table details
      description: Retrieve details about a table.
      operationId: tableDetails
      parameters:
        - description: Name of the database being looked up.
          name: database
          in: path
          required: true
          schema:
            type: string
        - description: >-
            Name of table being looked up. Table may be schema-qualified
            (schema.table) and each name component that contains sql unsafe
            characters such as . or uppercase letters must be surrounded in
            double quotes like "Naughty schema".table.
          name: table
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Database details response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/tableDetailsResponse'
        '404':
          description: Database or table not found
      x-codeSamples:
        - lang: curl
          source: |-
            curl --request GET \
              --url https://localhost/api/v2/databases/%7Bdatabase%7D/tables/%7Btable%7D/
components:
  schemas:
    tableDetailsResponse:
      $ref: '#/components/schemas/TableDetailsResponse'
    TableDetailsResponse:
      description: |-
        Grants, column names, and indexes for
        a table.
      type: object
      properties:
        columns:
          type: array
          items:
            $ref: '#/components/schemas/TableDetailsResponse_Column'
          x-go-name: Columns
        configure_zone_statement:
          description: >-
            The output of "SHOW ZONE CONFIGURATION FOR TABLE"

            for this table. It is a SQL statement that would re-configure the
            table's current

            zone if executed.
          type: string
          x-go-name: ConfigureZoneStatement
        create_table_statement:
          description: >-
            The output of "SHOW CREATE" for this table;

            it is a SQL statement that would re-create the table's current
            schema if

            executed.
          type: string
          x-go-name: CreateTableStatement
        descriptor_id:
          description: >-
            An identifier used to uniquely identify this table.

            It can be used to find events pertaining to this table by filtering
            on

            the `target_id` field of events.
          type: integer
          format: int64
          x-go-name: DescriptorID
        grants:
          type: array
          items:
            $ref: '#/components/schemas/TableDetailsResponse_Grant'
          x-go-name: Grants
        indexes:
          type: array
          items:
            $ref: '#/components/schemas/TableDetailsResponse_Index'
          x-go-name: Indexes
        range_count:
          description: |-
            The size of the table in ranges. This provides a rough
            estimate of the storage requirements for the table.
          type: integer
          format: int64
          x-go-name: RangeCount
        zone_config:
          $ref: '#/components/schemas/ZoneConfig'
        zone_config_level:
          $ref: '#/components/schemas/ZoneConfigurationLevel'
      x-go-package: github.com/cockroachdb/cockroach/pkg/server/serverpb
    TableDetailsResponse_Column:
      type: object
      properties:
        default_value:
          description: The default value of this column.
          type: string
          x-go-name: DefaultValue
        generation_expression:
          description: The generator expression if the column is computed.
          type: string
          x-go-name: GenerationExpression
        hidden:
          description: Whether this column is hidden.
          type: boolean
          x-go-name: Hidden
        name:
          description: The name of the column.
          type: string
          x-go-name: Name
        nullable:
          description: Whether this column can contain NULL.
          type: boolean
          x-go-name: Nullable
        type:
          description: the SQL type (e.g., INT, STRING) of this column.
          type: string
          x-go-name: Type
      x-go-package: github.com/cockroachdb/cockroach/pkg/server/serverpb
    TableDetailsResponse_Grant:
      type: object
      title: Grant is an entry from SHOW GRANTS.
      properties:
        privileges:
          description: Privileges granted to the user.
          type: array
          items:
            type: string
          x-go-name: Privileges
        user:
          description: User that this grant applies to.
          type: string
          x-go-name: User
      x-go-package: github.com/cockroachdb/cockroach/pkg/server/serverpb
    TableDetailsResponse_Index:
      type: object
      properties:
        column:
          description: The column that this index indexes.
          type: string
          x-go-name: Column
        direction:
          description: >-
            Direction of the response parameters. Either "ASC" (ascending) or
            "DESC" (descending).
          type: string
          x-go-name: Direction
        implicit:
          description: An internal variable that is passed.
          type: boolean
          x-go-name: Implicit
        name:
          description: The name of this index.
          type: string
          x-go-name: Name
        seq:
          description: An internal variable that is passed.
          type: integer
          format: int64
          x-go-name: Seq
        storing:
          description: An internal variable that is passed.
          type: boolean
          x-go-name: Storing
        unique:
          description: Whether this a unique index (i.e., CREATE UNIQUE INDEX).
          type: boolean
          x-go-name: Unique
      x-go-package: github.com/cockroachdb/cockroach/pkg/server/serverpb
    ZoneConfig:
      description: For internal use only.
      type: object
      title: ZoneConfig holds configuration that applies to one or more ranges.
      properties:
        constraints:
          description: >-
            Constrains which stores the replicas can be stored on. The

            order in which the constraints are stored is arbitrary and may
            change.
          type: array
          items:
            $ref: '#/components/schemas/ConstraintsConjunction'
          x-go-name: Constraints
        gc:
          $ref: '#/components/schemas/GCPolicy'
        global_reads:
          description: >-
            Whether transactions operating over the range(s)

            should be configured to provide non-blocking behavior, meaning that
            reads

            can be served consistently from all replicas and do not block on
            writes. In

            exchange, writes get pushed into the future and must wait on commit
            to

            ensure linearizability.
          type: boolean
          x-go-name: GlobalReads
        inherited_constraints:
          description: >-
            Whether the value in the Constraints field was

            inherited from the zone's parent or specified explicitly by the
            user.


            NB: We need this extra field because the non-nullable nature of

            `constraints` means that there is no other way to disambiguate
            between an

            unset `constraints` attribute and an empty one.
          type: boolean
          x-go-name: InheritedConstraints
        inherited_lease_preferences:
          description: >-
            Whether the value in the LeasePreferences field

            was inherited from the zone's parent or specified explicitly by the
            user.
          type: boolean
          x-go-name: InheritedLeasePreferences
        lease_preferences:
          description: >-
            Information about where the user would prefer for

            range leases to be placed. Leases are allowed to be placed elsewhere
            if

            needed, but will follow the provided preference when possible.


            More than one lease preference is allowed, but they should be
            ordered from

            most preferred to least preferred. The first preference that an
            existing

            replica of a range matches will take priority.
          type: array
          items:
            $ref: '#/components/schemas/LeasePreference'
          x-go-name: LeasePreferences
        null_voter_constraints_is_empty:
          description: >-
            Whether the `VoterConstraints` field

            was explicitly set to be empty or if it was inherited from its
            parent.


            NB: This extra field is needed because the non-nullable nature of

            `voter_constraints` means that there is no other way to disambiguate

            between an unset `voter_constraints` attribute and an empty one.


            This flag is not symmetric with `InheritedConstraints` defined
            above,

            and should only be checked when the list of `VoterConstraints` is
            empty (as

            otherwise they are assumed to _not_ be inherited) because we want
            21.1 (and

            future versions) nodes to correctly interpret zone configs persisted
            by

            pre-21.1 nodes. That is, in absence of explicit modifications, we
            want 21.1

            nodes to interpret that zone configs written by previous versions
            inherit

            `VoterConstraints` from their parent.
          type: boolean
          x-go-name: NullVoterConstraintsIsEmpty
        num_replicas:
          description: |-
            The desired number of replicas. This includes voting
            and non-voting replicas.
          type: integer
          format: int32
          x-go-name: NumReplicas
        num_voters:
          description: >-
            The desired number of voter replicas. If unspecified,

            there are no non-voting replicas and NumReplicas will represent the
            number

            of voters.
          type: integer
          format: int32
          x-go-name: NumVoters
        range_max_bytes:
          type: integer
          format: int64
          x-go-name: RangeMaxBytes
        range_min_bytes:
          type: integer
          format: int64
          x-go-name: RangeMinBytes
        subzone_spans:
          description: >-
            Each key span in a subzone mapped to the slice index of an entry

            in SubzoneConfig. Spans are non-overlapping and sorted by start key
            to

            allow binary searching. SubzoneSpans can be easily derived from a

            TableDescriptor, but are denormalized here to make
            GetZoneConfigForKey

            lookups efficient.
          type: array
          items:
            $ref: '#/components/schemas/SubzoneSpan'
          x-go-name: SubzoneSpans
        subzones:
          description: >-
            Config overrides for "subzones", each of which represents

            either a SQL table index or a partition of a SQL table index.
            Subzones are

            not applicable when the zone does not represent a SQL table (i.e.,
            when the

            zone represents a database, a special system range, or is itself a

            subzone.)
          type: array
          items:
            $ref: '#/components/schemas/Subzone'
          x-go-name: Subzones
        voter_constraints:
          description: >-
            Constrains which stores the voting replicas can be stored

            on. This field must be "compatible" with the `Constraints` field
            above, but

            not necessarily a subset. The `VoterConstraints` are said to be
            compatible

            with `Constraints` if none of the constraints in `Constraints`
            contradict

            any of the constraints in `VoterConstraints`. In other words, they
            are

            compatible if none of the "prohibitive" constraints in `Constraints`
            are

            "required" constraints in `VoterConstraints`.
          type: array
          items:
            $ref: '#/components/schemas/ConstraintsConjunction'
          x-go-name: VoterConstraints
      x-go-package: github.com/cockroachdb/cockroach/pkg/config/zonepb
    ZoneConfigurationLevel:
      description: |-
        The object level at which the configuration is defined. This is needed
        because objects without a specifically indicated Zone Configuration will
        inherit the configuration of their "parent".
      type: integer
      format: int32
      title: |-
        ZoneConfigurationLevel indicates, for objects with a Zone Configuration,
        the object level at which the configuration is defined. This is needed
        because objects without a specifically indicated Zone Configuration will
        inherit the configuration of their 'parent'.
        Valid levels are unknown (0), cluster (1), database (2), or table (3).
      x-go-package: github.com/cockroachdb/cockroach/pkg/server/serverpb
    ConstraintsConjunction:
      description: |-
        A set of constraints that need to be satisfied
        together by a replica (i.e., by the replica's store).
      type: object
      properties:
        constraints:
          description: >-
            The set of attributes and/or localities that need to be satisfied by
            the

            store.
          type: array
          items:
            $ref: '#/components/schemas/Constraint'
          x-go-name: Constraints
        num_replicas:
          description: >-
            The number of replicas that should abide by the constraints below.
            If left

            unspecified (i.e., set to 0), the constraints will apply to all
            replicas of

            the range.

            As of v2.0, only REQUIRED constraints are allowed when num_replicas
            is

            set to a non-zero value.
          type: integer
          format: int32
          x-go-name: NumReplicas
      x-go-package: github.com/cockroachdb/cockroach/pkg/config/zonepb
    GCPolicy:
      type: object
      title: |-
        GCPolicy defines garbage collection policies which apply to MVCC
        values within a zone.
      properties:
        ttl_seconds:
          description: |-
            TTLSeconds specifies the maximum age of a value before it's
            garbage collected. Only older versions of values are garbage
            collected. Specifying <= 0 mean older versions are never GC'd.
          type: integer
          format: int32
          x-go-name: TTLSeconds
      x-go-package: github.com/cockroachdb/cockroach/pkg/config/zonepb
    LeasePreference:
      description: |-
        A preference about where range leases should be
        located.
      type: object
      properties:
        constraints:
          type: array
          items:
            $ref: '#/components/schemas/Constraint'
          x-go-name: Constraints
      x-go-package: github.com/cockroachdb/cockroach/pkg/config/zonepb
    SubzoneSpan:
      type: object
      properties:
        end_key:
          $ref: '#/components/schemas/Key'
        key:
          $ref: '#/components/schemas/Key'
        subzone_index:
          description: |-
            The slice index of the Subzone this span belongs to in the
            parent ZoneConfig's subzones field.
          type: integer
          format: int32
          x-go-name: SubzoneIndex
      x-go-package: github.com/cockroachdb/cockroach/pkg/config/zonepb
    Subzone:
      type: object
      properties:
        config:
          $ref: '#/components/schemas/ZoneConfig'
        index_id:
          description: |-
            The ID of the SQL table index that the subzone represents.
            Always set.
          type: integer
          format: uint32
          x-go-name: IndexID
        partition_name:
          description: >-
            The partition of the SQL table index that the subzone

            represents. It is empty when the subzone represents the entire
            index.
          type: string
          x-go-name: PartitionName
      x-go-package: github.com/cockroachdb/cockroach/pkg/config/zonepb
    Constraint:
      type: object
      title: Constrains the stores that a replica can be stored on.
      properties:
        key:
          description: Only set if this is a constraint on locality.
          type: string
          x-go-name: Key
        type:
          $ref: '#/components/schemas/Constraint_Type'
        value:
          description: Value to constrain to.
          type: string
          x-go-name: Value
      x-go-package: github.com/cockroachdb/cockroach/pkg/config/zonepb
    Key:
      description: |-
        Key is a custom type for a byte string in proto
        messages which refer to Cockroach keys.
      type: array
      items:
        type: integer
        format: uint8
      x-go-package: github.com/cockroachdb/cockroach/pkg/roachpb
    Constraint_Type:
      type: integer
      format: int32
      x-go-package: github.com/cockroachdb/cockroach/pkg/config/zonepb

````