# 6.4.3 CREATE GROUP

Part of: [6 Language](6-language.md) › [6.4 Data Definition Language (DDL)](6-4-data-definition-language-ddl.md)

### Syntax

**CREATE** [**TRUNCATE**] [**AND** **USE**] **GROUP** [_file_name_] _group_name_ [**,** [_file_name_] _group_name_]\*\
[**ORDER** {**TRACKED** | **INDEXED**}]\
[**STORAGE** **COMPACT** _object_max_compact_ **DENSE** _object_min_dense_]\
[**ATTRIBUTE** [**ORDER** {**TRACKED** | **INDEXED**}] [**STORAGE** **COMPACT** _attribute_max_compact_ **DENSE** _attribute_min_dense_]]

### Description

Create an HDF5 group named _group_name_. Multiple groups can be created at once by separating their names with a comma (,). If _group_name_ already exists, it is not overwritten, no subsequent groups are created, and an error is raised. To overwrite an existing group, specify the keyword TRUNCATE (all data stored in the group will be permanently lost). In case the keyword AND USE is specified, the group is used (i.e. opened) after being successfully created (please refer to the operation [USE GROUP](6-8-3-use-group.md) for additional information). In case _group_name_ includes intermediate groups that do not exist, they are created automatically along with _group_name_ (e.g. when creating the group “my_group/my_subgroup/my_subsubgroup”, in addition to “my_subsubgroup” being created, “my_group” and “my_subgroup” are also created if they do not already exist). By default, _group_name_ does not track objects (i.e. groups, datasets, (soft) links, and external links) stored within it by their creation order. To track the creation order of objects stored in _group_name_, the keyword ORDER TRACKED must be specified. In case the keyword ORDER INDEXED is specified, objects stored within _group_name_ are also tracked by their creation order and using an index (to speed up retrieval of object names). By default, _group_name_ does not track attributes stored within it by their creation order. To track the creation order of attributes stored in _group_name_, the keyword ATTRIBUTE ORDER TRACKED must be specified. In case the keyword ATTRIBUTE ORDER INDEXED is specified, attributes stored within _group_name_ are also tracked by their creation order and using an index (to speed up retrieval of attribute names).

### Parameter(s)

_file_name_ – optional string that specifies the name of the HDF5 file in which the group is to be created. If _file_name_ is specified, the file is opened on the fly, the group is created within it, and the file is subsequently closed. If not specified, the file currently in use is used instead. As a general rule, in case _file_name_ contains spaces or special characters, it should be enclosed in double quotes (“). Otherwise, if it is not enclosed in double quotes, the group is not created, and an error is raised. This rule also applies to any other HDFql operation that works with file names (e.g. [RENAME FILE](6-4-10-rename-file.md)).

_group_name_ – mandatory string that specifies the name of the HDF5 group to create. As a general rule, in case _group_name_ contains spaces or special characters, it should be enclosed in double quotes (“). Otherwise, if it is not enclosed in double quotes, the group is not created, and an error is raised. This rule also applies to any other HDFql operation that works with group names (e.g. [RENAME GROUP](6-4-11-rename.md)).

_object_max_compact_ – optional integer that specifies the maximum number of links (i.e. objects) to store in the compact format. In case the number of links (stored in _group_name_) exceeds _object_max_compact_, the storage of links switches to the dense format. If not specified, its default value is 8 (defined by the HDF5 library).

_object_min_dense_ – optional integer that specifies the minimum number of links (i.e. objects) to store in the dense format. In case the number of links (stored in _group_name_) falls below _object_min_dense_, the storage of links switches to the compact format. If not specified, its default value is 6 (defined by the HDF5 library).

_attribute_max_compact_ – optional integer that specifies the maximum number of attributes to store in the compact format. In case the number of attributes (stored in _group_name_) exceeds _attribute_max_compact_, the storage of attributes switches to the dense format. If not specified, its default value is 8 (defined by the HDF5 library).

_attribute_min_dense_ – optional integer that specifies the minimum number of attributes to store in the dense format. In case the number of attributes (stored in _group_name_) falls below _attribute_min_dense_, the storage of attributes switches to the compact format. If not specified, its default value is 6 (defined by the HDF5 library).

### Return

Nothing

### Example(s)

```hdfql
# create an HDF5 group named "my_group0" (the group will not be overwritten if it already exists)
CREATE GROUP my_group0

# create an HDF5 group named "my_subgroup0" in a root group named "my_group1" (neither group will be overwritten if they already exist; group "my_group1" will be created automatically if it does not exist)
CREATE GROUP /my_group1/my_subgroup0

# create two HDF5 groups named "my_group2" and "my_group3" (both groups will be overwritten if they already exist)
CREATE TRUNCATE GROUP my_group2, my_group3

# create an HDF5 group named "this is a long group name" (the group will not be overwritten if it already exists) and use (i.e. open) it for subsequent operations
CREATE AND USE GROUP "this is a long group name"
```

```hdfql
# create an HDF5 group named "my_group4" that tracks the objects’ (i.e. groups and datasets) creation order within the group and using compact storage
CREATE GROUP my_group4 ORDER TRACKED STORAGE COMPACT 10 DENSE 7

# create an HDF5 group named "my_group5" that indexes the creation order of attributes 
CREATE GROUP my_group5 ATTRIBUTE ORDER INDEXED
```

```hdfql
# use (i.e. open) an HDF5 file named "my_file.h5" 
USE FILE my_file.h5

# create an HDF5 group named "my_group6" in the HDF5 file currently in use (i.e. file "my_file.h5")
CREATE GROUP my_group6

# close HDF5 file currently in use (i.e. file "my_file.h5") 
CLOSE FILE 

# create an HDF5 group named "my_group7" in file "my_file.h5" 
CREATE GROUP my_file.h5 my_group7
```
