CREATE OR REPLACE: Grants on the replaced object are copied by default (Disabled by default)¶
Attention
This behavior change is in the 2026_08 bundle.
For the current status of the bundle, refer to Bundle history.
When this behavior change bundle is enabled, COPY GRANTS becomes the default behavior for a
CREATE OR REPLACE statement that replaces an object that already exists: the privilege grants on the
replaced object are copied to the replacement automatically, as though
COPY GRANTS had been specified. The
change applies to tables, views, materialized views, streams, semantic views, functions, procedures,
and Cortex Agents.
- Before the change:
A
CREATE OR REPLACEstatement that didn’t specifyCOPY GRANTSdropped the privileges that had been granted on the replaced object. Retaining those privileges required specifyingCOPY GRANTSexplicitly.Separately, whether the replacement object inherited any future grants defined for that object type in the schema or database depended on the object type:
- For tables, views, and materialized views, the replacement object inherited future grants only when
COPY GRANTSwas not specified. - For streams, semantic views, functions, procedures, and Cortex Agents, the replacement object always
inherited future grants, regardless of whether
COPY GRANTSwas specified.
By default, the role that executed the statement owned the replacement object; if the replacement object inherited a future grant of the
OWNERSHIPprivilege, as described above, the role named in that future grant owned it instead.- For tables, views, and materialized views, the replacement object inherited future grants only when
- After the change:
All privileges except
OWNERSHIPare copied from the replaced object to the replacement object. Whether future grants also apply depends on the object type:- For tables, views, and materialized views, future grants defined for the object type in the schema
apply to the replacement object as follows:
- A future grant of the
OWNERSHIPprivilege is always applied: the role named in that future grant owns the replacement object, and the copied privileges are retained. - A future grant of any other privilege is applied only if the replaced object had no explicit access
privileges (other than
OWNERSHIP) to copy; in that case, all future grants defined for the object type in the schema are applied, as ifCOPY GRANTSweren’t used.
- A future grant of the
- For streams, semantic views, functions, procedures, and Cortex Agents, future grants defined for the object type in the schema always apply to the replacement object, in addition to the copied privileges.
By default, the role that executes the statement owns the replacement object, unless a future grant of the
OWNERSHIPprivilege applies, in which case the role named in that future grant owns it instead. To drop the grants instead, specify the newIGNORE GRANTSclause, which requiresOR REPLACEand can’t be combined withCOPY GRANTS:Because
IGNORE GRANTSdrops the privileges on the replaced object instead of copying them, the replacement object inherits all future grants defined for the object type in the schema, regardless of object type or whether the replaced object had any privileges to copy.Grants are copied only when the statement replaces an object that already exists. A
CREATE OR REPLACE ... LIKEorCREATE OR REPLACE ... CLONEstatement that creates a new object still copies grants from theLIKEorCLONEsource only whenCOPY GRANTSis specified.Because a grant to a share is now copied along with other grants, replacing a secure view or secure function with a non-secure one fails if the object is granted to a share whose
SECURE_OBJECTS_ONLYproperty isTRUE:- For tables, views, and materialized views, future grants defined for the object type in the schema
apply to the replacement object as follows:
How to update your code¶
Review CREATE OR REPLACE statements in pipelines and deployment scripts that relied on the previous
behavior: grants being dropped on replace, or future grants applying to the replacement object instead.
Dropping grants on CREATE OR REPLACE is a common source of unintended loss of access: a routine rebuild
of a table, view, or function silently revokes the privileges that consumers depend on, and the failure
surfaces later as an insufficient-privileges error in a downstream workload.
To keep the previous behavior for a specific statement, add IGNORE GRANTS:
Before replacing a secure view or secure function with a non-secure version, check whether the object is
granted to a share whose SECURE_OBJECTS_ONLY property is TRUE. If it is, the replacement fails with
error 090838 until you update the share setting or the grant.
Ref: 2433