CREATE OR ALTER VERSIONED SCHEMA¶
创建新的版本化架构或修改现有的版本化架构。仅 Native Apps Framework 中的应用程序实例支持此命令。
- See also:
语法
必填参数
name指定架构的标识符;对于在其中创建架构的数据库来说,此标识符必须是唯一的。
In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (e.g.
"My object"). Identifiers enclosed in double quotes are also case-sensitive.For more details, see Identifier requirements.
可选参数
WITH MANAGED ACCESS指定带有版本控制的托管架构。带有版本控制的托管访问架构通过架构所有者集中进行权限管理。
在常规带有版本控制的架构中,对象所有者(即具有对对象的 OWNERSHIP 权限的角色)可以将其对象的更多权限授予其他角色。
In managed schemas, the schema owner manages all privilege grants, including future grants, on objects in the schema. Object owners retain the OWNERSHIP privileges on the objects, however, only the schema owner can manage privilege grants on the objects.
DATA_RETENTION_TIME_IN_DAYS = integerSpecifies the number of days for which Time Travel actions (CLONE and UNDROP) can be performed on the schema, as well as specifying the default Time Travel retention time for all tables created in the schema. For more details, refer Understanding & using Time Travel.
For a detailed description of this object-level parameter, as well as more information about object parameters, refer to Parameters. For more information about table-level retention time, refer to CREATE TABLE and Understanding & using Time Travel.
值:
- Standard Edition:
0or1 - Enterprise Edition:
0to90for permanent schemas0or1for transient schemas
默认:
- Standard Edition:
1 - Enterprise Edition (or higher):
1(unless a different default value was specified at the database or account level)
Note
A value of
0effectively disables Time Travel for the schema.- Standard Edition:
MAX_DATA_EXTENSION_TIME_IN_DAYS = integer对象参数,指定 Snowflake 可以延长架构内表的数据保留期以防止表上的流过时的最大天数。
For a detailed description of this parameter, see MAX_DATA_EXTENSION_TIME_IN_DAYS.
DEFAULT_DDL_COLLATION = 'collation_specification'Specifies a default collation specification for all tables added to the schema. The default can be overridden at the individual table level.
For more details about the parameter, see DEFAULT_DDL_COLLATION.
COMMENT = 'string_literal'指定架构的注释。
默认:无值
访问控制要求
A role used to execute this operation must have the following privileges at a minimum:
| 权限 | 对象 | 备注 |
|---|---|---|
| CREATE SCHEMA | 应用程序 | 如果架构已存在,并且您想修改该架构,则需要具备应用程序的 OWNERSHIP 权限。 |
For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.
For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.
Note
虽然您通常会在设置脚本中创建带有版本控制的架构,但也可以通过如下方式创建带有版本控制的架构:
- 通过具有所有者权限的存储过程。
- 在使用者账户中,使用对应用程序具有 CREATE SCHEMA 权限的应用程序角色。
使用说明
- 如果架构不存在,Snowflake 会创建带有版本控制的架构。
- 如果架构存在且已与命令匹配,Snowflake 会将此视为不执行任何操作。
- 如果架构存在,但与命令不匹配,Snowflake 会修改带有版本控制的架构以匹配命令。