SequoiaDB giant sequoia database-createCL () overviewOne

name

createCL-Create a new collection.

grammar

db.collectionspace.createCL(<name>,[options])

category

Collection Space

description

Create a collection in the designated collection space. A collection is a logical object that stores document records in the database. Any document record must belong to one and only one collection.

parameter

  • name (  Stringrequired  )

    Collection name. In the same collection space, the collection name must be unique.

  • options (  Objectoptional  )

    When creating a collection, you can optionsset other properties of the collection through parameters, such as specifying the partition key of the collection, whether to insert data in a compressed form, etc. options The following options can be used in combination  :

    1. ShardingKey (  Object  ): The partition key.

      format:ShardingKey:{<字段1> : <1|-1>,[<字段2> : <1|-1>, ...]}

    2. ShardingType (  String  ): Partition method. The default is hash partition. The selectable values ​​are as follows:

      • "hash": hash partition.
      • "range": Range partition.

      format:ShardingType:"hash"|"range"

    3. Partition (  Int32  ): The number of partitions. It is only filled when the hash partition is selected, which represents the number of hash partitions. Its value must be a power of 2. The range is [2^3, 2^20]. The default is 4096.

      format:Partition: <分区数>

    4. ReplSize (  Int32  ): The number of copies to be synchronized for write operations. The default value is 1. The selectable values ​​are as follows:

      • -1: Indicates that the write request needs to be synchronized to several active nodes in the replication group before the database write operation returns a response to the client.
      • 0: Indicates that the write request needs to be synchronized to all nodes in the replication group before the database write operation returns a response to the client.
      • 1-7: Indicates that the write request needs to be synchronized to the specified number of nodes in the replication group before the database write operation returns a response to the client.

      format:ReplSize: <num>

    5. Compressed (  Bool  ): indicates whether the data compression function is enabled for the new collection. The default is true.

      format:Compressed:true|false

    6. CompressionType (  String  ): Compression algorithm type. The default is the lzw algorithm. The selectable values ​​are as follows:

      • "snappy": Use snappy algorithm to compress.
      • "lzw": Use lzw algorithm to compress.

      format:CompressionType:"snappy"|"lzw"

    7. IsMainCL (  Bool  ): Indicate whether the new collection is the primary partition collection, the default is false.

      format:IsMainCL:true|false

    8. AutoSplit (  Bool  ): indicates whether the automatic segmentation function is enabled for the new collection, the default is false.

      format:AutoSplit:true|false

    9. Group (  String  ): Specify the replication group to which the new collection will be created.

      format:Group:<group name>

    10. AutoIndexId (  Bool  ): Indicate whether the new collection automatically uses the _id field to create a unique index named "$id", the default is true.

      format:AutoIndexId:true|false

    11. EnsureShardingIndex (  Bool  ): Indicates whether the collection automatically uses the fields contained in ShardingKey to create an index named "$shard", the default is true.

      format:EnsureShardingIndex:true|false

    12. StrictDataMode (  Bool  ): indicates whether the strict data type mode is enabled for the operation of the collection, the default is false (not enabled). The opening flag of strict data mode has the following restrictions on numerical operations:

      • The data type is not changed during the operation;
      • When the numerical calculation overflows, an error will be reported directly, the error code SDB_VALUE_OVERFLOW;

      format:StrictDataMode:true|false

    13. AutoIncrement (  Object  ): Auto-increment field

      Format: AutoIncrement:{Field: <字段>, ...} or AutoIncrement:[ {Field: <字段1>, ...}, {Field: <字段2>, ...}, ... ]

      example:AutoIncrement: { Field: "userID", Generated: "always" }

    14. LobShardingKeyFormat (  String  ): Specifies the format of the split key value of the main table generated by the large object. Currently, it is supported to convert the time attribute in the large object ID into the following string form:

      • "YYYYMMDD": Convert the time attribute of the large object ID into a string form of year, month, and day, such as "20190701".
      • "YYYYMM": Convert the time attribute of the large object ID into a string form of year and month, such as "201907".
      • "YYYY": Convert the time attribute of the large object ID to the string form of the year, such as "2019".

      format:LobShardingKeyFormat:"YYYYMMDD"|"YYYYMM"|"YYYY"

Note:

  • Please refer to Restrictions for collection name restrictions

  • When options multiple parameters  are set in the parameter, the value of each parameter must be separated by a comma "," in English.

  • When creating a collection space , you can specify the data domain to which it belongs . When creating a collection, use the Group parameter and the specified replication group must be in the domain; without using the Group parameter, the collection will be created on any replication group in the domain.

  • The AutoSplit parameter that creates the collection has higher priority than the AutoSplit property of the data field.

  • AutoSplit cannot be used together with the Group parameter.

  • AutoSplit must be used with hash partitioning.

  • Compression algorithm selection strategy: The snappy compression algorithm compresses a single record as the unit, and the repetition of data within the record directly affects the compression rate. Therefore, when the internal data repetition of records is high, such as the field names and field values ​​of each record are similar, the snappy algorithm can be used to obtain good compression performance. If the internal data repetition of the records is very low, but the records have higher similarity, such as the same field names and similar field values ​​between different records, the lzw algorithm is better.

  • LobShardingKeyFormat can only be used in the main table, and it is required that the split key can only have one split field.

For more information, please click on the official website of Jushan Database

Guess you like

Origin blog.csdn.net/weixin_48909806/article/details/112624246