createCollection
Creates a new collection. SingleStore Kai for MongoDB creates a collection implicitly on write. By default, the createCollection
command creates a columnstore table.
Syntax
db.createCollection(<name>, { timeseries: { timeField: <string> }, rowStore: <boolean> shardKey: <document> sortKey: <document> indexes: <array> columns: <array> preserveJSONKeyOrder: <boolean> } )
Option | Type | Description |
---|---|---|
| String | Creates a top-level |
| Boolean | When enabled, creates a rowstore table. |
| Document | Defines a shard key for the collection at creation in the index format. For example, |
| Document | Defines a |
| Array | Each document in the array contains an index definition in the type specified in |
| Array | Each document in the array represents a top-level column that is created in the table supporting this collection, with an |
| Boolean | When enabled, key order is recorded by adding a field named |
The following options are not supported in a createCollection
statement:
capped
timeseries.metaField
timeseries.granularity
clusteredIndex
changeStreamPreAndPostImages
size
max
storageEngine
validator
validationLevel
validationAction
indexOptionDefaults
viewOn
pipeline
collation
writeConcern
Examples
The following examples show how to use the createCollection
command:
Create a collection named exampleC with a field named Code:
db.createCollection("exampleC", { columns: [{ id: "Code", type: "BIGINT NOT NULL" }], });
Create a collection supported by a rowstore table:
db.createCollection("exCollection", { rowstore: true });