---
title: STRUCT type
description: The STRUCT type represents values with a structure described by a sequence of fields in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/data-types/struct-type
---

# `STRUCT` type

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Represents values with the structure described by a sequence of fields.

## Syntax

```
STRUCT < [fieldName [:] fieldType [NOT NULL] [COLLATE collationName] [COMMENT str] [, …] ] >
```

* `fieldName`: An identifier naming the field. The names need not be unique.

* `fieldType`: Any data type.

* `NOT NULL`: When specified, the struct guarantees that the value of this field is never `NULL`.

* `COLLATE` [collationName](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md#collation-name): This optionally specifies the collation to use for a `fieldType` of `STRING`.

  If not specified the collation is inherited from the context in which the `STRUCT` is defined:

  * Within a `CREATE` or `ALTER` of a `TABLE`, `VIEW`, `FUNCTION`, or `PROCEDURE`, the default collation matches the default collation of that object.
  * Within the context of a top level [UPDATE](https://docs.databricks.com/aws/en/sql/language-manual/delta-update.md) , [DELETE](https://docs.databricks.com/aws/en/sql/language-manual/delta-delete-from.md), [INSERT](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-dml-insert-into.md), [MERGE](https://docs.databricks.com/aws/en/sql/language-manual/delta-merge-into.md) or [query statement](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-query.md) the default collation is the [session collation](https://docs.databricks.com/aws/en/sql/language-manual/parameters/collation.md).

* `COMMENT str`: An optional string literal describing the field.

## Limits

The type supports any number of fields greater or equal to 0.

## Literals

See [`struct` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/struct.md) and [`named_struct` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/named_struct.md) for details on how to produce literal array values.

## Examples

```sql
> SELECT struct('Spark', 5);
  {Spark, 5}

> SELECT typeof(named_struct('Field1', 'Spark', 'Field2', 5));
  struct<Field1:string,Field2:int>

> SELECT typeof(struct('Spark', 5));
  struct<col1:string,col2:int>

> SELECT typeof(CAST(NULL AS STRUCT<Field1:INT NOT NULL COMMENT 'The first field.',Field2:ARRAY<INT>>));
  struct<Field1:int,Field2:array<int>>

> SELECT collation(cast(struct('hello') AS STRUCT<name STRING COLLATE UNICODE_CI>).name);
 SYSTEM.BUILTIN.UNICODE_CI
```

## Related

* [`ARRAY` type](https://docs.databricks.com/aws/en/sql/language-manual/data-types/array-type.md)
* [`MAP` type](https://docs.databricks.com/aws/en/sql/language-manual/data-types/map-type.md)
* [`struct` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/struct.md)
* [`named_struct` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/named_struct.md)
* [`cast` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/cast.md)
