ALIYUN::POLARDB::Database

ALIYUN::POLARDB::Database类型用于为PolarDB集群创建一个新的数据库。

语法

{
  "Type": "ALIYUN::POLARDB::Database",
  "Properties": {
    "CharacterSetName": String,
    "DBClusterId": String,
    "DBName": String,
    "AccountPrivilege": String,
    "AccountName": String,
    "Collate": String,
    "Ctype": String,
    "DBDescription": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

CharacterSetName

String

字符集。

关于字符集的取值范围,请参见字符集表

DBClusterId

String

集群ID。

DBName

String

数据库名称。

名称需满足如下要求:

  • 由小写字母、数字、中划线(-)、下划线(_)组成。

  • 以字母开头,以字母或数字结尾,最长64个字符。

AccountPrivilege

String

账号权限。

取值范围如下:

  • ReadWrite:读写。

  • ReadOnly:只读。

  • DMLOnly:只允许DML。

  • DDLOnly:只允许DDL。

  • ReadIndex:只读+索引。

若该参数不填,则默认为ReadWrite。

说明
  • 该参数仅当AccountName为非空值时生效。

  • 当集群为PolarDB PostgreSQL版(兼容Oracle)或PolarDB PostgreSQL版时,该参数必填;

  • 当集群为PolarDB MySQL版时,该参数非必填。

AccountName

String

授权访问该数据库的账号名。

说明
  • 只支持输入普通账号,高权限账号默认拥有数据库全部权限无需授权。

  • 当集群为PolarDB PostgreSQL版(兼容Oracle)或PolarDB PostgreSQL版时,该参数必填;当集群为PolarDB MySQL版时,该参数非必填。

Collate

String

语言环境设置。

用于指定新建数据库的排序规则。

说明
  • 语言环境必须与CharacterSetName参数设置的字符集兼容。

  • 当集群为PolarDB PostgreSQL版(兼容Oracle)或PolarDB PostgreSQL版时,该参数必填;当集群为PolarDB MySQL版时,不支持该参数。

    关于该参数的取值范围,请登录PolarDB控制台,在配置与管理 > 数据库管理页签,单击创建数据库进行查看。

Ctype

String

语言环境设置。

用于指定数据库的字符分类。

说明
  • 语言环境必须与CharacterSetName参数设置的字符集兼容。

  • 与Collate传入信息一致。

  • 当集群为PolarDB PostgreSQL版(兼容Oracle)或PolarDB PostgreSQL版时,该参数必填;当集群为PolarDB MySQL版时,该参数非必填。

    关于该参数的取值范围,请登录PolarDB控制台,在配置与管理 > 数据库管理页签,单击创建数据库进行查看。

DBDescription

String

数据库备注信息。

备注信息需满足如下要求:

  • 不能以http://https://开头。

  • 长度为2~256个字符。

说明

当集群为PolarDB PostgreSQL版(兼容Oracle)或PolarDB PostgreSQL版时,该参数必填;当集群为PolarDB MySQL版时,该参数非必填。

返回值

Fn::GetAtt

示例

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  CharacterSetName:
    AssociationPropertyMetadata:
      AutoChangeType: false
    Type: String
    Description:
      en: The character set of the database. For more information, see Character sets.
    AllowedValues:
      - utf8
      - geostd8
      - gbk
      - greek
      - utf8mb4
      - hebrew
      - latin1
      - hp8
      - euckr
      - keybcs2
      - armscii8
      - koi8r
      - ascii
      - koi8u
      - big5
      - latin2
      - binary
      - latin5
      - cp1250
      - latin7
      - cp1251
      - macce
      - cp1256
      - macroman
      - cp1257
      - sjis
      - cp850
      - swe7
      - cp852
      - tis620
      - cp866
      - ucs2
      - cp932
      - ujis
      - dec8
      - utf16
      - eucjpms
      - utf16le
      - gb2312
    Required: true
  DBClusterId:
    AssociationProperty: ALIYUN::POLARDB::DBCluster::DBClusterId
    Type: String
    Description:
      en: The ID of the ApsaraDB for POLARDB cluster for which a database is to be created.
    Required: true
  DBName:
    Type: String
    Description:
      en: |-
        The name of the database to be created. The name must comply with the following rules:
        It must start with a lowercase letter and consist of lowercase letters, digits, hyphens
        (-), and underscores (_).
        It must end with a letter or a digit. It can be up to 64 characters in length.
    AllowedPattern: ^[a-z0-9][-_a-z0-9]{0,63}(?<![-_]$)$
    Required: true
Resources:
  Database:
    Type: ALIYUN::POLARDB::Database
    Properties:
      CharacterSetName:
        Ref: CharacterSetName
      DBClusterId:
        Ref: DBClusterId
      DBName:
        Ref: DBName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "CharacterSetName": {
      "AssociationPropertyMetadata": {
        "AutoChangeType": false
      },
      "Type": "String",
      "Description": {
        "en": "The character set of the database. For more information, see Character sets."
      },
      "AllowedValues": [
        "utf8",
        "geostd8",
        "gbk",
        "greek",
        "utf8mb4",
        "hebrew",
        "latin1",
        "hp8",
        "euckr",
        "keybcs2",
        "armscii8",
        "koi8r",
        "ascii",
        "koi8u",
        "big5",
        "latin2",
        "binary",
        "latin5",
        "cp1250",
        "latin7",
        "cp1251",
        "macce",
        "cp1256",
        "macroman",
        "cp1257",
        "sjis",
        "cp850",
        "swe7",
        "cp852",
        "tis620",
        "cp866",
        "ucs2",
        "cp932",
        "ujis",
        "dec8",
        "utf16",
        "eucjpms",
        "utf16le",
        "gb2312"
      ],
      "Required": true
    },
    "DBClusterId": {
      "AssociationProperty": "ALIYUN::POLARDB::DBCluster::DBClusterId",
      "Type": "String",
      "Description": {
        "en": "The ID of the ApsaraDB for POLARDB cluster for which a database is to be created."
      },
      "Required": true
    },
    "DBName": {
      "Type": "String",
      "Description": {
        "en": "The name of the database to be created. The name must comply with the following rules:\nIt must start with a lowercase letter and consist of lowercase letters, digits, hyphens\n(-), and underscores (_).\nIt must end with a letter or a digit. It can be up to 64 characters in length."
      },
      "AllowedPattern": "^[a-z0-9][-_a-z0-9]{0,63}(?<![-_]$)$",
      "Required": true
    },
  },
  "Resources": {
    "Database": {
      "Type": "ALIYUN::POLARDB::Database",
      "Properties": {
        "CharacterSetName": {
          "Ref": "CharacterSetName"
        },
        "DBClusterId": {
          "Ref": "DBClusterId"
        },
        "DBName": {
          "Ref": "DBName"
        }
      }
    }
  }
}