From 9b27711f66070f83d4af944e782c1de41698dbf4 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Mon, 8 Jun 2026 01:45:10 -0400 Subject: [PATCH 1/4] Fix ALTER SEQUENCE required privileges Verified against running v24.3 and v26.3-dev servers and the CockroachDB source: - A base `ALTER SEQUENCE` (for example, changing `INCREMENT`) requires the user to be the owner of the sequence. The pages previously claimed `CREATE` on the parent database, which is neither sufficient nor grantable on a sequence ("some privileges have no effect on sequences: [CREATE]"). - `ALTER SEQUENCE ... RENAME TO` requires `DROP` on the sequence and `CREATE` on the sequence's database. `ALTER SEQUENCE ... SET SCHEMA` requires `DROP` on the sequence and `CREATE` on the new schema. The pages previously omitted `DROP` and pointed `SET SCHEMA` at the parent database instead of the new schema. Co-Authored-By: roachdev-claude --- src/current/v23.1/alter-sequence.md | 5 +++-- src/current/v23.2/alter-sequence.md | 5 +++-- src/current/v24.1/alter-sequence.md | 5 +++-- src/current/v24.2/alter-sequence.md | 5 +++-- src/current/v24.3/alter-sequence.md | 5 +++-- src/current/v25.1/alter-sequence.md | 5 +++-- src/current/v25.2/alter-sequence.md | 5 +++-- src/current/v25.3/alter-sequence.md | 5 +++-- src/current/v25.4/alter-sequence.md | 5 +++-- src/current/v26.1/alter-sequence.md | 5 +++-- src/current/v26.2/alter-sequence.md | 5 +++-- src/current/v26.3/alter-sequence.md | 5 +++-- 12 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/current/v23.1/alter-sequence.md b/src/current/v23.1/alter-sequence.md index e6718e72d1e..7d8d27e6f59 100644 --- a/src/current/v23.1/alter-sequence.md +++ b/src/current/v23.1/alter-sequence.md @@ -11,8 +11,9 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen ## Required privileges -- To alter a sequence, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, or to change the database of a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence. +- To alter a sequence, the user must be the owner of the sequence. +- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. +- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. ## Syntax diff --git a/src/current/v23.2/alter-sequence.md b/src/current/v23.2/alter-sequence.md index e6718e72d1e..7d8d27e6f59 100644 --- a/src/current/v23.2/alter-sequence.md +++ b/src/current/v23.2/alter-sequence.md @@ -11,8 +11,9 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen ## Required privileges -- To alter a sequence, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, or to change the database of a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence. +- To alter a sequence, the user must be the owner of the sequence. +- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. +- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. ## Syntax diff --git a/src/current/v24.1/alter-sequence.md b/src/current/v24.1/alter-sequence.md index e6718e72d1e..7d8d27e6f59 100644 --- a/src/current/v24.1/alter-sequence.md +++ b/src/current/v24.1/alter-sequence.md @@ -11,8 +11,9 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen ## Required privileges -- To alter a sequence, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, or to change the database of a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence. +- To alter a sequence, the user must be the owner of the sequence. +- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. +- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. ## Syntax diff --git a/src/current/v24.2/alter-sequence.md b/src/current/v24.2/alter-sequence.md index e6718e72d1e..7d8d27e6f59 100644 --- a/src/current/v24.2/alter-sequence.md +++ b/src/current/v24.2/alter-sequence.md @@ -11,8 +11,9 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen ## Required privileges -- To alter a sequence, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, or to change the database of a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence. +- To alter a sequence, the user must be the owner of the sequence. +- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. +- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. ## Syntax diff --git a/src/current/v24.3/alter-sequence.md b/src/current/v24.3/alter-sequence.md index e6718e72d1e..7d8d27e6f59 100644 --- a/src/current/v24.3/alter-sequence.md +++ b/src/current/v24.3/alter-sequence.md @@ -11,8 +11,9 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen ## Required privileges -- To alter a sequence, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, or to change the database of a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence. +- To alter a sequence, the user must be the owner of the sequence. +- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. +- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. ## Syntax diff --git a/src/current/v25.1/alter-sequence.md b/src/current/v25.1/alter-sequence.md index e6718e72d1e..7d8d27e6f59 100644 --- a/src/current/v25.1/alter-sequence.md +++ b/src/current/v25.1/alter-sequence.md @@ -11,8 +11,9 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen ## Required privileges -- To alter a sequence, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, or to change the database of a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence. +- To alter a sequence, the user must be the owner of the sequence. +- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. +- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. ## Syntax diff --git a/src/current/v25.2/alter-sequence.md b/src/current/v25.2/alter-sequence.md index e6718e72d1e..7d8d27e6f59 100644 --- a/src/current/v25.2/alter-sequence.md +++ b/src/current/v25.2/alter-sequence.md @@ -11,8 +11,9 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen ## Required privileges -- To alter a sequence, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, or to change the database of a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence. +- To alter a sequence, the user must be the owner of the sequence. +- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. +- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. ## Syntax diff --git a/src/current/v25.3/alter-sequence.md b/src/current/v25.3/alter-sequence.md index 689d5c52c8b..02abc08ec41 100644 --- a/src/current/v25.3/alter-sequence.md +++ b/src/current/v25.3/alter-sequence.md @@ -11,8 +11,9 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen ## Required privileges -- To alter a sequence, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, or to change the database of a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence. +- To alter a sequence, the user must be the owner of the sequence. +- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. +- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. ## Syntax diff --git a/src/current/v25.4/alter-sequence.md b/src/current/v25.4/alter-sequence.md index 4d83a5302f6..062b228e3c4 100644 --- a/src/current/v25.4/alter-sequence.md +++ b/src/current/v25.4/alter-sequence.md @@ -11,8 +11,9 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen ## Required privileges -- To alter a sequence, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, or to change the database of a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence. +- To alter a sequence, the user must be the owner of the sequence. +- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. +- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. ## Syntax diff --git a/src/current/v26.1/alter-sequence.md b/src/current/v26.1/alter-sequence.md index 4d83a5302f6..062b228e3c4 100644 --- a/src/current/v26.1/alter-sequence.md +++ b/src/current/v26.1/alter-sequence.md @@ -11,8 +11,9 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen ## Required privileges -- To alter a sequence, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, or to change the database of a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence. +- To alter a sequence, the user must be the owner of the sequence. +- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. +- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. ## Syntax diff --git a/src/current/v26.2/alter-sequence.md b/src/current/v26.2/alter-sequence.md index 4d83a5302f6..062b228e3c4 100644 --- a/src/current/v26.2/alter-sequence.md +++ b/src/current/v26.2/alter-sequence.md @@ -11,8 +11,9 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen ## Required privileges -- To alter a sequence, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, or to change the database of a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence. +- To alter a sequence, the user must be the owner of the sequence. +- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. +- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. ## Syntax diff --git a/src/current/v26.3/alter-sequence.md b/src/current/v26.3/alter-sequence.md index 8087e472752..298413465a7 100644 --- a/src/current/v26.3/alter-sequence.md +++ b/src/current/v26.3/alter-sequence.md @@ -11,8 +11,9 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen ## Required privileges -- To alter a sequence, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, or to change the database of a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence. +- To alter a sequence, the user must be the owner of the sequence. +- To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. +- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. ## Syntax From dd69e89ee2e5a76ebea8b667788b6dd66b947534 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Mon, 8 Jun 2026 01:45:29 -0400 Subject: [PATCH 2/4] Remove incorrect cross-database rename claims from ALTER TABLE/VIEW/SEQUENCE `ALTER TABLE/VIEW/SEQUENCE ... RENAME TO` cannot move a relation to a different database; doing so errors with "cannot change database of table using alter table rename to". This has been the behavior since the `PublicSchemasWithDescriptors` migration (v22.1), confirmed on both v24.3 and v26.3-dev, so the claims were incorrect for every documented release. - ALTER SEQUENCE: removed the "Change the database of a sequence" example and reworded the `RENAME TO` parameter note. - ALTER VIEW: reworded the note that claimed rename can move a view to another database. - ALTER TABLE: removed the sentence stating the user needs `CREATE` on both source and target databases when "moving a table from one database to another". `RENAME TO` only changes the name of the relation; use `SET SCHEMA` to change the schema. Co-Authored-By: roachdev-claude --- src/current/v23.1/alter-sequence.md | 51 +---------------------------- src/current/v23.1/alter-table.md | 2 +- src/current/v23.1/alter-view.md | 2 +- src/current/v23.2/alter-sequence.md | 51 +---------------------------- src/current/v23.2/alter-table.md | 2 +- src/current/v23.2/alter-view.md | 2 +- src/current/v24.1/alter-sequence.md | 51 +---------------------------- src/current/v24.1/alter-table.md | 2 +- src/current/v24.1/alter-view.md | 2 +- src/current/v24.2/alter-sequence.md | 51 +---------------------------- src/current/v24.2/alter-table.md | 2 +- src/current/v24.2/alter-view.md | 2 +- src/current/v24.3/alter-sequence.md | 51 +---------------------------- src/current/v24.3/alter-table.md | 2 +- src/current/v24.3/alter-view.md | 2 +- src/current/v25.1/alter-sequence.md | 51 +---------------------------- src/current/v25.1/alter-table.md | 2 +- src/current/v25.1/alter-view.md | 2 +- src/current/v25.2/alter-sequence.md | 51 +---------------------------- src/current/v25.2/alter-table.md | 2 +- src/current/v25.2/alter-view.md | 2 +- src/current/v25.3/alter-sequence.md | 51 +---------------------------- src/current/v25.3/alter-table.md | 2 +- src/current/v25.3/alter-view.md | 2 +- src/current/v25.4/alter-sequence.md | 51 +---------------------------- src/current/v25.4/alter-table.md | 2 +- src/current/v25.4/alter-view.md | 2 +- src/current/v26.1/alter-sequence.md | 51 +---------------------------- src/current/v26.1/alter-table.md | 2 +- src/current/v26.1/alter-view.md | 2 +- src/current/v26.2/alter-sequence.md | 51 +---------------------------- src/current/v26.2/alter-table.md | 2 +- src/current/v26.2/alter-view.md | 2 +- src/current/v26.3/alter-sequence.md | 51 +---------------------------- src/current/v26.3/alter-table.md | 2 +- src/current/v26.3/alter-view.md | 2 +- 36 files changed, 36 insertions(+), 624 deletions(-) diff --git a/src/current/v23.1/alter-sequence.md b/src/current/v23.1/alter-sequence.md index 7d8d27e6f59..5131a2e63dd 100644 --- a/src/current/v23.1/alter-sequence.md +++ b/src/current/v23.1/alter-sequence.md @@ -27,7 +27,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen -----------|------------ `IF EXISTS` | Modify the sequence only if it exists; if it does not exist, do not return an error. `sequence_name` | The name of the sequence. -`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

Note that `RENAME TO` can be used to move a sequence from one database to another, but it cannot be used to move a sequence from one schema to another. To change a sequence's schema, use `ALTER SEQUENCE ...SET SCHEMA` instead. +`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

`RENAME TO` only changes the name of the sequence; it cannot move the sequence to a different database or schema. To change a sequence's schema, use `ALTER SEQUENCE ... SET SCHEMA` instead. `CYCLE`/`NO CYCLE` | The sequence will wrap around when the sequence value reaches the maximum or minimum value. `CYCLE` is not implemented. If `NO CYCLE` is set, the sequence will not wrap. `OWNED BY column_name` | Associates the sequence to a particular column. If that column or its parent table is dropped, the sequence will also be dropped.

Specifying an owner column with `OWNED BY` replaces any existing owner column on the sequence. To remove existing column ownership on the sequence and make the column free-standing, specify `OWNED BY NONE`.

**Default:** `NONE` `CACHE` | The number of sequence values to cache in memory for reuse in the session. A cache size of `1` means that there is no cache, and cache sizes of less than `1` are not valid.

**Default:** `1` (sequences are not cached by default) @@ -113,55 +113,6 @@ In this example, we will change the name of sequence. (1 row) ~~~ -### Change the database of a sequence - -In this example, we will move the sequence we renamed in the first example (`even_sequence`) from `defaultdb` (i.e., the default database) to a different database. - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> CREATE DATABASE mydb; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> ALTER SEQUENCE even_sequence RENAME TO mydb.even_sequence; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- -(0 rows) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM mydb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - ### Change the schema of a sequence Suppose you [create a sequence]({% link {{ page.version.version }}/create-sequence.md %}) that you would like to add to a new schema called `cockroach_labs`: diff --git a/src/current/v23.1/alter-table.md b/src/current/v23.1/alter-table.md index f5dbd3f58b1..ca96524a62e 100644 --- a/src/current/v23.1/alter-table.md +++ b/src/current/v23.1/alter-table.md @@ -448,7 +448,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. #### Parameters diff --git a/src/current/v23.1/alter-view.md b/src/current/v23.1/alter-view.md index 77c8a880236..8f23021bd5f 100644 --- a/src/current/v23.1/alter-view.md +++ b/src/current/v23.1/alter-view.md @@ -81,7 +81,7 @@ WITH x AS (SHOW TABLES) SELECT * FROM x WHERE type = 'view'; (1 row) ~~~ -Note that `RENAME TO` can be used to move a view from one database to another, but it cannot be used to move a view from one schema to another. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). In a future release, `RENAME TO` will be limited to changing the name of a view, and will not have the ability to change a view's database. +Note that `RENAME TO` only changes the name of the view; it cannot move the view to a different database or schema. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). ### Change the schema of a view diff --git a/src/current/v23.2/alter-sequence.md b/src/current/v23.2/alter-sequence.md index 7d8d27e6f59..5131a2e63dd 100644 --- a/src/current/v23.2/alter-sequence.md +++ b/src/current/v23.2/alter-sequence.md @@ -27,7 +27,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen -----------|------------ `IF EXISTS` | Modify the sequence only if it exists; if it does not exist, do not return an error. `sequence_name` | The name of the sequence. -`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

Note that `RENAME TO` can be used to move a sequence from one database to another, but it cannot be used to move a sequence from one schema to another. To change a sequence's schema, use `ALTER SEQUENCE ...SET SCHEMA` instead. +`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

`RENAME TO` only changes the name of the sequence; it cannot move the sequence to a different database or schema. To change a sequence's schema, use `ALTER SEQUENCE ... SET SCHEMA` instead. `CYCLE`/`NO CYCLE` | The sequence will wrap around when the sequence value reaches the maximum or minimum value. `CYCLE` is not implemented. If `NO CYCLE` is set, the sequence will not wrap. `OWNED BY column_name` | Associates the sequence to a particular column. If that column or its parent table is dropped, the sequence will also be dropped.

Specifying an owner column with `OWNED BY` replaces any existing owner column on the sequence. To remove existing column ownership on the sequence and make the column free-standing, specify `OWNED BY NONE`.

**Default:** `NONE` `CACHE` | The number of sequence values to cache in memory for reuse in the session. A cache size of `1` means that there is no cache, and cache sizes of less than `1` are not valid.

**Default:** `1` (sequences are not cached by default) @@ -113,55 +113,6 @@ In this example, we will change the name of sequence. (1 row) ~~~ -### Change the database of a sequence - -In this example, we will move the sequence we renamed in the first example (`even_sequence`) from `defaultdb` (i.e., the default database) to a different database. - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> CREATE DATABASE mydb; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> ALTER SEQUENCE even_sequence RENAME TO mydb.even_sequence; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- -(0 rows) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM mydb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - ### Change the schema of a sequence Suppose you [create a sequence]({% link {{ page.version.version }}/create-sequence.md %}) that you would like to add to a new schema called `cockroach_labs`: diff --git a/src/current/v23.2/alter-table.md b/src/current/v23.2/alter-table.md index c82962672d9..b9d8274fbb9 100644 --- a/src/current/v23.2/alter-table.md +++ b/src/current/v23.2/alter-table.md @@ -449,7 +449,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. #### Parameters diff --git a/src/current/v23.2/alter-view.md b/src/current/v23.2/alter-view.md index 77c8a880236..8f23021bd5f 100644 --- a/src/current/v23.2/alter-view.md +++ b/src/current/v23.2/alter-view.md @@ -81,7 +81,7 @@ WITH x AS (SHOW TABLES) SELECT * FROM x WHERE type = 'view'; (1 row) ~~~ -Note that `RENAME TO` can be used to move a view from one database to another, but it cannot be used to move a view from one schema to another. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). In a future release, `RENAME TO` will be limited to changing the name of a view, and will not have the ability to change a view's database. +Note that `RENAME TO` only changes the name of the view; it cannot move the view to a different database or schema. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). ### Change the schema of a view diff --git a/src/current/v24.1/alter-sequence.md b/src/current/v24.1/alter-sequence.md index 7d8d27e6f59..5131a2e63dd 100644 --- a/src/current/v24.1/alter-sequence.md +++ b/src/current/v24.1/alter-sequence.md @@ -27,7 +27,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen -----------|------------ `IF EXISTS` | Modify the sequence only if it exists; if it does not exist, do not return an error. `sequence_name` | The name of the sequence. -`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

Note that `RENAME TO` can be used to move a sequence from one database to another, but it cannot be used to move a sequence from one schema to another. To change a sequence's schema, use `ALTER SEQUENCE ...SET SCHEMA` instead. +`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

`RENAME TO` only changes the name of the sequence; it cannot move the sequence to a different database or schema. To change a sequence's schema, use `ALTER SEQUENCE ... SET SCHEMA` instead. `CYCLE`/`NO CYCLE` | The sequence will wrap around when the sequence value reaches the maximum or minimum value. `CYCLE` is not implemented. If `NO CYCLE` is set, the sequence will not wrap. `OWNED BY column_name` | Associates the sequence to a particular column. If that column or its parent table is dropped, the sequence will also be dropped.

Specifying an owner column with `OWNED BY` replaces any existing owner column on the sequence. To remove existing column ownership on the sequence and make the column free-standing, specify `OWNED BY NONE`.

**Default:** `NONE` `CACHE` | The number of sequence values to cache in memory for reuse in the session. A cache size of `1` means that there is no cache, and cache sizes of less than `1` are not valid.

**Default:** `1` (sequences are not cached by default) @@ -113,55 +113,6 @@ In this example, we will change the name of sequence. (1 row) ~~~ -### Change the database of a sequence - -In this example, we will move the sequence we renamed in the first example (`even_sequence`) from `defaultdb` (i.e., the default database) to a different database. - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> CREATE DATABASE mydb; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> ALTER SEQUENCE even_sequence RENAME TO mydb.even_sequence; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- -(0 rows) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM mydb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - ### Change the schema of a sequence Suppose you [create a sequence]({% link {{ page.version.version }}/create-sequence.md %}) that you would like to add to a new schema called `cockroach_labs`: diff --git a/src/current/v24.1/alter-table.md b/src/current/v24.1/alter-table.md index fec50321d18..7dfc544391c 100644 --- a/src/current/v24.1/alter-table.md +++ b/src/current/v24.1/alter-table.md @@ -439,7 +439,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. #### Parameters diff --git a/src/current/v24.1/alter-view.md b/src/current/v24.1/alter-view.md index 8b7248cd4d6..298b0f1f2b7 100644 --- a/src/current/v24.1/alter-view.md +++ b/src/current/v24.1/alter-view.md @@ -78,7 +78,7 @@ WITH x AS (SHOW TABLES) SELECT * FROM x WHERE type = 'view'; (1 row) ~~~ -Note that `RENAME TO` can be used to move a view from one database to another, but it cannot be used to move a view from one schema to another. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). In a future release, `RENAME TO` will be limited to changing the name of a view, and will not have the ability to change a view's database. +Note that `RENAME TO` only changes the name of the view; it cannot move the view to a different database or schema. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). ### Change the schema of a view diff --git a/src/current/v24.2/alter-sequence.md b/src/current/v24.2/alter-sequence.md index 7d8d27e6f59..5131a2e63dd 100644 --- a/src/current/v24.2/alter-sequence.md +++ b/src/current/v24.2/alter-sequence.md @@ -27,7 +27,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen -----------|------------ `IF EXISTS` | Modify the sequence only if it exists; if it does not exist, do not return an error. `sequence_name` | The name of the sequence. -`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

Note that `RENAME TO` can be used to move a sequence from one database to another, but it cannot be used to move a sequence from one schema to another. To change a sequence's schema, use `ALTER SEQUENCE ...SET SCHEMA` instead. +`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

`RENAME TO` only changes the name of the sequence; it cannot move the sequence to a different database or schema. To change a sequence's schema, use `ALTER SEQUENCE ... SET SCHEMA` instead. `CYCLE`/`NO CYCLE` | The sequence will wrap around when the sequence value reaches the maximum or minimum value. `CYCLE` is not implemented. If `NO CYCLE` is set, the sequence will not wrap. `OWNED BY column_name` | Associates the sequence to a particular column. If that column or its parent table is dropped, the sequence will also be dropped.

Specifying an owner column with `OWNED BY` replaces any existing owner column on the sequence. To remove existing column ownership on the sequence and make the column free-standing, specify `OWNED BY NONE`.

**Default:** `NONE` `CACHE` | The number of sequence values to cache in memory for reuse in the session. A cache size of `1` means that there is no cache, and cache sizes of less than `1` are not valid.

**Default:** `1` (sequences are not cached by default) @@ -113,55 +113,6 @@ In this example, we will change the name of sequence. (1 row) ~~~ -### Change the database of a sequence - -In this example, we will move the sequence we renamed in the first example (`even_sequence`) from `defaultdb` (i.e., the default database) to a different database. - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> CREATE DATABASE mydb; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> ALTER SEQUENCE even_sequence RENAME TO mydb.even_sequence; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- -(0 rows) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM mydb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - ### Change the schema of a sequence Suppose you [create a sequence]({% link {{ page.version.version }}/create-sequence.md %}) that you would like to add to a new schema called `cockroach_labs`: diff --git a/src/current/v24.2/alter-table.md b/src/current/v24.2/alter-table.md index e533514fbb4..bf233996b00 100644 --- a/src/current/v24.2/alter-table.md +++ b/src/current/v24.2/alter-table.md @@ -438,7 +438,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. #### Parameters diff --git a/src/current/v24.2/alter-view.md b/src/current/v24.2/alter-view.md index 8b7248cd4d6..298b0f1f2b7 100644 --- a/src/current/v24.2/alter-view.md +++ b/src/current/v24.2/alter-view.md @@ -78,7 +78,7 @@ WITH x AS (SHOW TABLES) SELECT * FROM x WHERE type = 'view'; (1 row) ~~~ -Note that `RENAME TO` can be used to move a view from one database to another, but it cannot be used to move a view from one schema to another. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). In a future release, `RENAME TO` will be limited to changing the name of a view, and will not have the ability to change a view's database. +Note that `RENAME TO` only changes the name of the view; it cannot move the view to a different database or schema. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). ### Change the schema of a view diff --git a/src/current/v24.3/alter-sequence.md b/src/current/v24.3/alter-sequence.md index 7d8d27e6f59..5131a2e63dd 100644 --- a/src/current/v24.3/alter-sequence.md +++ b/src/current/v24.3/alter-sequence.md @@ -27,7 +27,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen -----------|------------ `IF EXISTS` | Modify the sequence only if it exists; if it does not exist, do not return an error. `sequence_name` | The name of the sequence. -`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

Note that `RENAME TO` can be used to move a sequence from one database to another, but it cannot be used to move a sequence from one schema to another. To change a sequence's schema, use `ALTER SEQUENCE ...SET SCHEMA` instead. +`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

`RENAME TO` only changes the name of the sequence; it cannot move the sequence to a different database or schema. To change a sequence's schema, use `ALTER SEQUENCE ... SET SCHEMA` instead. `CYCLE`/`NO CYCLE` | The sequence will wrap around when the sequence value reaches the maximum or minimum value. `CYCLE` is not implemented. If `NO CYCLE` is set, the sequence will not wrap. `OWNED BY column_name` | Associates the sequence to a particular column. If that column or its parent table is dropped, the sequence will also be dropped.

Specifying an owner column with `OWNED BY` replaces any existing owner column on the sequence. To remove existing column ownership on the sequence and make the column free-standing, specify `OWNED BY NONE`.

**Default:** `NONE` `CACHE` | The number of sequence values to cache in memory for reuse in the session. A cache size of `1` means that there is no cache, and cache sizes of less than `1` are not valid.

**Default:** `1` (sequences are not cached by default) @@ -113,55 +113,6 @@ In this example, we will change the name of sequence. (1 row) ~~~ -### Change the database of a sequence - -In this example, we will move the sequence we renamed in the first example (`even_sequence`) from `defaultdb` (i.e., the default database) to a different database. - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> CREATE DATABASE mydb; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> ALTER SEQUENCE even_sequence RENAME TO mydb.even_sequence; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- -(0 rows) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM mydb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - ### Change the schema of a sequence Suppose you [create a sequence]({% link {{ page.version.version }}/create-sequence.md %}) that you would like to add to a new schema called `cockroach_labs`: diff --git a/src/current/v24.3/alter-table.md b/src/current/v24.3/alter-table.md index fec50321d18..7dfc544391c 100644 --- a/src/current/v24.3/alter-table.md +++ b/src/current/v24.3/alter-table.md @@ -439,7 +439,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. #### Parameters diff --git a/src/current/v24.3/alter-view.md b/src/current/v24.3/alter-view.md index 8b7248cd4d6..298b0f1f2b7 100644 --- a/src/current/v24.3/alter-view.md +++ b/src/current/v24.3/alter-view.md @@ -78,7 +78,7 @@ WITH x AS (SHOW TABLES) SELECT * FROM x WHERE type = 'view'; (1 row) ~~~ -Note that `RENAME TO` can be used to move a view from one database to another, but it cannot be used to move a view from one schema to another. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). In a future release, `RENAME TO` will be limited to changing the name of a view, and will not have the ability to change a view's database. +Note that `RENAME TO` only changes the name of the view; it cannot move the view to a different database or schema. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). ### Change the schema of a view diff --git a/src/current/v25.1/alter-sequence.md b/src/current/v25.1/alter-sequence.md index 7d8d27e6f59..5131a2e63dd 100644 --- a/src/current/v25.1/alter-sequence.md +++ b/src/current/v25.1/alter-sequence.md @@ -27,7 +27,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen -----------|------------ `IF EXISTS` | Modify the sequence only if it exists; if it does not exist, do not return an error. `sequence_name` | The name of the sequence. -`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

Note that `RENAME TO` can be used to move a sequence from one database to another, but it cannot be used to move a sequence from one schema to another. To change a sequence's schema, use `ALTER SEQUENCE ...SET SCHEMA` instead. +`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

`RENAME TO` only changes the name of the sequence; it cannot move the sequence to a different database or schema. To change a sequence's schema, use `ALTER SEQUENCE ... SET SCHEMA` instead. `CYCLE`/`NO CYCLE` | The sequence will wrap around when the sequence value reaches the maximum or minimum value. `CYCLE` is not implemented. If `NO CYCLE` is set, the sequence will not wrap. `OWNED BY column_name` | Associates the sequence to a particular column. If that column or its parent table is dropped, the sequence will also be dropped.

Specifying an owner column with `OWNED BY` replaces any existing owner column on the sequence. To remove existing column ownership on the sequence and make the column free-standing, specify `OWNED BY NONE`.

**Default:** `NONE` `CACHE` | The number of sequence values to cache in memory for reuse in the session. A cache size of `1` means that there is no cache, and cache sizes of less than `1` are not valid.

**Default:** `1` (sequences are not cached by default) @@ -113,55 +113,6 @@ In this example, we will change the name of sequence. (1 row) ~~~ -### Change the database of a sequence - -In this example, we will move the sequence we renamed in the first example (`even_sequence`) from `defaultdb` (i.e., the default database) to a different database. - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> CREATE DATABASE mydb; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> ALTER SEQUENCE even_sequence RENAME TO mydb.even_sequence; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- -(0 rows) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM mydb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - ### Change the schema of a sequence Suppose you [create a sequence]({% link {{ page.version.version }}/create-sequence.md %}) that you would like to add to a new schema called `cockroach_labs`: diff --git a/src/current/v25.1/alter-table.md b/src/current/v25.1/alter-table.md index c67c8b62722..c2459cd4a4e 100644 --- a/src/current/v25.1/alter-table.md +++ b/src/current/v25.1/alter-table.md @@ -436,7 +436,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. #### Parameters diff --git a/src/current/v25.1/alter-view.md b/src/current/v25.1/alter-view.md index 8b7248cd4d6..298b0f1f2b7 100644 --- a/src/current/v25.1/alter-view.md +++ b/src/current/v25.1/alter-view.md @@ -78,7 +78,7 @@ WITH x AS (SHOW TABLES) SELECT * FROM x WHERE type = 'view'; (1 row) ~~~ -Note that `RENAME TO` can be used to move a view from one database to another, but it cannot be used to move a view from one schema to another. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). In a future release, `RENAME TO` will be limited to changing the name of a view, and will not have the ability to change a view's database. +Note that `RENAME TO` only changes the name of the view; it cannot move the view to a different database or schema. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). ### Change the schema of a view diff --git a/src/current/v25.2/alter-sequence.md b/src/current/v25.2/alter-sequence.md index 7d8d27e6f59..5131a2e63dd 100644 --- a/src/current/v25.2/alter-sequence.md +++ b/src/current/v25.2/alter-sequence.md @@ -27,7 +27,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen -----------|------------ `IF EXISTS` | Modify the sequence only if it exists; if it does not exist, do not return an error. `sequence_name` | The name of the sequence. -`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

Note that `RENAME TO` can be used to move a sequence from one database to another, but it cannot be used to move a sequence from one schema to another. To change a sequence's schema, use `ALTER SEQUENCE ...SET SCHEMA` instead. +`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

`RENAME TO` only changes the name of the sequence; it cannot move the sequence to a different database or schema. To change a sequence's schema, use `ALTER SEQUENCE ... SET SCHEMA` instead. `CYCLE`/`NO CYCLE` | The sequence will wrap around when the sequence value reaches the maximum or minimum value. `CYCLE` is not implemented. If `NO CYCLE` is set, the sequence will not wrap. `OWNED BY column_name` | Associates the sequence to a particular column. If that column or its parent table is dropped, the sequence will also be dropped.

Specifying an owner column with `OWNED BY` replaces any existing owner column on the sequence. To remove existing column ownership on the sequence and make the column free-standing, specify `OWNED BY NONE`.

**Default:** `NONE` `CACHE` | The number of sequence values to cache in memory for reuse in the session. A cache size of `1` means that there is no cache, and cache sizes of less than `1` are not valid.

**Default:** `1` (sequences are not cached by default) @@ -113,55 +113,6 @@ In this example, we will change the name of sequence. (1 row) ~~~ -### Change the database of a sequence - -In this example, we will move the sequence we renamed in the first example (`even_sequence`) from `defaultdb` (i.e., the default database) to a different database. - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> CREATE DATABASE mydb; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> ALTER SEQUENCE even_sequence RENAME TO mydb.even_sequence; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- -(0 rows) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM mydb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - ### Change the schema of a sequence Suppose you [create a sequence]({% link {{ page.version.version }}/create-sequence.md %}) that you would like to add to a new schema called `cockroach_labs`: diff --git a/src/current/v25.2/alter-table.md b/src/current/v25.2/alter-table.md index 927c98371d6..0242e39746e 100644 --- a/src/current/v25.2/alter-table.md +++ b/src/current/v25.2/alter-table.md @@ -440,7 +440,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. #### Parameters diff --git a/src/current/v25.2/alter-view.md b/src/current/v25.2/alter-view.md index 8b7248cd4d6..298b0f1f2b7 100644 --- a/src/current/v25.2/alter-view.md +++ b/src/current/v25.2/alter-view.md @@ -78,7 +78,7 @@ WITH x AS (SHOW TABLES) SELECT * FROM x WHERE type = 'view'; (1 row) ~~~ -Note that `RENAME TO` can be used to move a view from one database to another, but it cannot be used to move a view from one schema to another. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). In a future release, `RENAME TO` will be limited to changing the name of a view, and will not have the ability to change a view's database. +Note that `RENAME TO` only changes the name of the view; it cannot move the view to a different database or schema. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). ### Change the schema of a view diff --git a/src/current/v25.3/alter-sequence.md b/src/current/v25.3/alter-sequence.md index 02abc08ec41..6d9c26a961c 100644 --- a/src/current/v25.3/alter-sequence.md +++ b/src/current/v25.3/alter-sequence.md @@ -27,7 +27,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen -----------|------------ `IF EXISTS` | Modify the sequence only if it exists; if it does not exist, do not return an error. `sequence_name` | The name of the sequence. -`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

Note that `RENAME TO` can be used to move a sequence from one database to another, but it cannot be used to move a sequence from one schema to another. To change a sequence's schema, use `ALTER SEQUENCE ...SET SCHEMA` instead. +`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

`RENAME TO` only changes the name of the sequence; it cannot move the sequence to a different database or schema. To change a sequence's schema, use `ALTER SEQUENCE ... SET SCHEMA` instead. `CYCLE`/`NO CYCLE` | The sequence will wrap around when the sequence value reaches the maximum or minimum value. `CYCLE` is not implemented. If `NO CYCLE` is set, the sequence will not wrap. `OWNED BY column_name` | Associates the sequence to a particular column. If that column or its parent table is dropped, the sequence will also be dropped.

Specifying an owner column with `OWNED BY` replaces any existing owner column on the sequence. To remove existing column ownership on the sequence and make the column free-standing, specify `OWNED BY NONE`.

**Default:** `NONE` `CACHE` | The number of sequence values to cache in memory at the [node]({% link {{ page.version.version }}/architecture/overview.md %}#node) level. All sessions on the node share the same cache, which can be concurrently accessed, and which reduces the chance of creating large gaps between generated IDs. A cache size of `1` means that there is no cache, and cache sizes of less than `1` are not valid.

**Default:** `1` (sequences are not cached by default). While this parameter caches sequences per node, to cache sequence values per session, use [`PER SESSION CACHE`](#per-session-cache) explicitly. @@ -115,55 +115,6 @@ In this example, we will change the name of sequence. (1 row) ~~~ -### Change the database of a sequence - -In this example, we will move the sequence we renamed in the first example (`even_sequence`) from `defaultdb` (i.e., the default database) to a different database. - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> CREATE DATABASE mydb; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> ALTER SEQUENCE even_sequence RENAME TO mydb.even_sequence; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- -(0 rows) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM mydb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - ### Change the schema of a sequence Suppose you [create a sequence]({% link {{ page.version.version }}/create-sequence.md %}) that you would like to add to a new schema called `cockroach_labs`: diff --git a/src/current/v25.3/alter-table.md b/src/current/v25.3/alter-table.md index fcb7511e81f..48782abf86f 100644 --- a/src/current/v25.3/alter-table.md +++ b/src/current/v25.3/alter-table.md @@ -440,7 +440,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. #### Parameters diff --git a/src/current/v25.3/alter-view.md b/src/current/v25.3/alter-view.md index 8b7248cd4d6..298b0f1f2b7 100644 --- a/src/current/v25.3/alter-view.md +++ b/src/current/v25.3/alter-view.md @@ -78,7 +78,7 @@ WITH x AS (SHOW TABLES) SELECT * FROM x WHERE type = 'view'; (1 row) ~~~ -Note that `RENAME TO` can be used to move a view from one database to another, but it cannot be used to move a view from one schema to another. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). In a future release, `RENAME TO` will be limited to changing the name of a view, and will not have the ability to change a view's database. +Note that `RENAME TO` only changes the name of the view; it cannot move the view to a different database or schema. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). ### Change the schema of a view diff --git a/src/current/v25.4/alter-sequence.md b/src/current/v25.4/alter-sequence.md index 062b228e3c4..bcc9dbc0214 100644 --- a/src/current/v25.4/alter-sequence.md +++ b/src/current/v25.4/alter-sequence.md @@ -27,7 +27,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen -----------|------------ `IF EXISTS` | Modify the sequence only if it exists; if it does not exist, do not return an error. `sequence_name` | The name of the sequence. -`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

Note that `RENAME TO` can be used to move a sequence from one database to another, but it cannot be used to move a sequence from one schema to another. To change a sequence's schema, use `ALTER SEQUENCE ...SET SCHEMA` instead. +`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

`RENAME TO` only changes the name of the sequence; it cannot move the sequence to a different database or schema. To change a sequence's schema, use `ALTER SEQUENCE ... SET SCHEMA` instead. `CYCLE`/`NO CYCLE` | The sequence will wrap around when the sequence value reaches the maximum or minimum value. `CYCLE` is not implemented. If `NO CYCLE` is set, the sequence will not wrap. `OWNED BY column_name` | Associates the sequence to a particular column. If that column or its parent table is dropped, the sequence will also be dropped.

Specifying an owner column with `OWNED BY` replaces any existing owner column on the sequence. To remove existing column ownership on the sequence and make the column free-standing, specify `OWNED BY NONE`.

**Default:** `NONE` `CACHE` | The number of sequence values to cache in memory at the [node]({% link {{ page.version.version }}/architecture/overview.md %}#node) level. All sessions on the node share the same cache, which can be concurrently accessed, and which reduces the chance of creating large gaps between generated IDs. A cache size of `1` means that there is no cache, and cache sizes of less than `1` are not valid.

**Default:** `1` (sequences are not cached by default). While this parameter caches sequences per node, to cache sequence values per session, use [`PER SESSION CACHE`](#per-session-cache) explicitly. @@ -115,55 +115,6 @@ In this example, we will change the name of sequence. (1 row) ~~~ -### Change the database of a sequence - -In this example, we will move the sequence we renamed in the first example (`even_sequence`) from `defaultdb` (i.e., the default database) to a different database. - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> CREATE DATABASE mydb; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> ALTER SEQUENCE even_sequence RENAME TO mydb.even_sequence; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- -(0 rows) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM mydb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - ### Change the schema of a sequence Suppose you [create a sequence]({% link {{ page.version.version }}/create-sequence.md %}) that you would like to add to a new schema called `cockroach_labs`: diff --git a/src/current/v25.4/alter-table.md b/src/current/v25.4/alter-table.md index 5b101c45fd0..dfd63981f8a 100644 --- a/src/current/v25.4/alter-table.md +++ b/src/current/v25.4/alter-table.md @@ -444,7 +444,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. #### Parameters diff --git a/src/current/v25.4/alter-view.md b/src/current/v25.4/alter-view.md index 8b7248cd4d6..298b0f1f2b7 100644 --- a/src/current/v25.4/alter-view.md +++ b/src/current/v25.4/alter-view.md @@ -78,7 +78,7 @@ WITH x AS (SHOW TABLES) SELECT * FROM x WHERE type = 'view'; (1 row) ~~~ -Note that `RENAME TO` can be used to move a view from one database to another, but it cannot be used to move a view from one schema to another. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). In a future release, `RENAME TO` will be limited to changing the name of a view, and will not have the ability to change a view's database. +Note that `RENAME TO` only changes the name of the view; it cannot move the view to a different database or schema. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). ### Change the schema of a view diff --git a/src/current/v26.1/alter-sequence.md b/src/current/v26.1/alter-sequence.md index 062b228e3c4..bcc9dbc0214 100644 --- a/src/current/v26.1/alter-sequence.md +++ b/src/current/v26.1/alter-sequence.md @@ -27,7 +27,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen -----------|------------ `IF EXISTS` | Modify the sequence only if it exists; if it does not exist, do not return an error. `sequence_name` | The name of the sequence. -`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

Note that `RENAME TO` can be used to move a sequence from one database to another, but it cannot be used to move a sequence from one schema to another. To change a sequence's schema, use `ALTER SEQUENCE ...SET SCHEMA` instead. +`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

`RENAME TO` only changes the name of the sequence; it cannot move the sequence to a different database or schema. To change a sequence's schema, use `ALTER SEQUENCE ... SET SCHEMA` instead. `CYCLE`/`NO CYCLE` | The sequence will wrap around when the sequence value reaches the maximum or minimum value. `CYCLE` is not implemented. If `NO CYCLE` is set, the sequence will not wrap. `OWNED BY column_name` | Associates the sequence to a particular column. If that column or its parent table is dropped, the sequence will also be dropped.

Specifying an owner column with `OWNED BY` replaces any existing owner column on the sequence. To remove existing column ownership on the sequence and make the column free-standing, specify `OWNED BY NONE`.

**Default:** `NONE` `CACHE` | The number of sequence values to cache in memory at the [node]({% link {{ page.version.version }}/architecture/overview.md %}#node) level. All sessions on the node share the same cache, which can be concurrently accessed, and which reduces the chance of creating large gaps between generated IDs. A cache size of `1` means that there is no cache, and cache sizes of less than `1` are not valid.

**Default:** `1` (sequences are not cached by default). While this parameter caches sequences per node, to cache sequence values per session, use [`PER SESSION CACHE`](#per-session-cache) explicitly. @@ -115,55 +115,6 @@ In this example, we will change the name of sequence. (1 row) ~~~ -### Change the database of a sequence - -In this example, we will move the sequence we renamed in the first example (`even_sequence`) from `defaultdb` (i.e., the default database) to a different database. - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> CREATE DATABASE mydb; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> ALTER SEQUENCE even_sequence RENAME TO mydb.even_sequence; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- -(0 rows) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM mydb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - ### Change the schema of a sequence Suppose you [create a sequence]({% link {{ page.version.version }}/create-sequence.md %}) that you would like to add to a new schema called `cockroach_labs`: diff --git a/src/current/v26.1/alter-table.md b/src/current/v26.1/alter-table.md index 0f65ffbf3c3..e77d6ee1add 100644 --- a/src/current/v26.1/alter-table.md +++ b/src/current/v26.1/alter-table.md @@ -444,7 +444,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. #### Parameters diff --git a/src/current/v26.1/alter-view.md b/src/current/v26.1/alter-view.md index 8b7248cd4d6..298b0f1f2b7 100644 --- a/src/current/v26.1/alter-view.md +++ b/src/current/v26.1/alter-view.md @@ -78,7 +78,7 @@ WITH x AS (SHOW TABLES) SELECT * FROM x WHERE type = 'view'; (1 row) ~~~ -Note that `RENAME TO` can be used to move a view from one database to another, but it cannot be used to move a view from one schema to another. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). In a future release, `RENAME TO` will be limited to changing the name of a view, and will not have the ability to change a view's database. +Note that `RENAME TO` only changes the name of the view; it cannot move the view to a different database or schema. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). ### Change the schema of a view diff --git a/src/current/v26.2/alter-sequence.md b/src/current/v26.2/alter-sequence.md index 062b228e3c4..bcc9dbc0214 100644 --- a/src/current/v26.2/alter-sequence.md +++ b/src/current/v26.2/alter-sequence.md @@ -27,7 +27,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen -----------|------------ `IF EXISTS` | Modify the sequence only if it exists; if it does not exist, do not return an error. `sequence_name` | The name of the sequence. -`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

Note that `RENAME TO` can be used to move a sequence from one database to another, but it cannot be used to move a sequence from one schema to another. To change a sequence's schema, use `ALTER SEQUENCE ...SET SCHEMA` instead. +`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

`RENAME TO` only changes the name of the sequence; it cannot move the sequence to a different database or schema. To change a sequence's schema, use `ALTER SEQUENCE ... SET SCHEMA` instead. `CYCLE`/`NO CYCLE` | The sequence will wrap around when the sequence value reaches the maximum or minimum value. `CYCLE` is not implemented. If `NO CYCLE` is set, the sequence will not wrap. `OWNED BY column_name` | Associates the sequence to a particular column. If that column or its parent table is dropped, the sequence will also be dropped.

Specifying an owner column with `OWNED BY` replaces any existing owner column on the sequence. To remove existing column ownership on the sequence and make the column free-standing, specify `OWNED BY NONE`.

**Default:** `NONE` `CACHE` | The number of sequence values to cache in memory at the [node]({% link {{ page.version.version }}/architecture/overview.md %}#node) level. All sessions on the node share the same cache, which can be concurrently accessed, and which reduces the chance of creating large gaps between generated IDs. A cache size of `1` means that there is no cache, and cache sizes of less than `1` are not valid.

**Default:** `1` (sequences are not cached by default). While this parameter caches sequences per node, to cache sequence values per session, use [`PER SESSION CACHE`](#per-session-cache) explicitly. @@ -115,55 +115,6 @@ In this example, we will change the name of sequence. (1 row) ~~~ -### Change the database of a sequence - -In this example, we will move the sequence we renamed in the first example (`even_sequence`) from `defaultdb` (i.e., the default database) to a different database. - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> CREATE DATABASE mydb; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> ALTER SEQUENCE even_sequence RENAME TO mydb.even_sequence; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- -(0 rows) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM mydb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - ### Change the schema of a sequence Suppose you [create a sequence]({% link {{ page.version.version }}/create-sequence.md %}) that you would like to add to a new schema called `cockroach_labs`: diff --git a/src/current/v26.2/alter-table.md b/src/current/v26.2/alter-table.md index c1c2fa23d5c..8b5ecd55b61 100644 --- a/src/current/v26.2/alter-table.md +++ b/src/current/v26.2/alter-table.md @@ -446,7 +446,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. #### Parameters diff --git a/src/current/v26.2/alter-view.md b/src/current/v26.2/alter-view.md index 0c46271ac80..3d69be40b50 100644 --- a/src/current/v26.2/alter-view.md +++ b/src/current/v26.2/alter-view.md @@ -80,7 +80,7 @@ WITH x AS (SHOW TABLES) SELECT * FROM x WHERE type = 'view'; (1 row) ~~~ -Note that `RENAME TO` can be used to move a view from one database to another, but it cannot be used to move a view from one schema to another. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). In a future release, `RENAME TO` will be limited to changing the name of a view, and will not have the ability to change a view's database. +Note that `RENAME TO` only changes the name of the view; it cannot move the view to a different database or schema. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). ### Change the schema of a view diff --git a/src/current/v26.3/alter-sequence.md b/src/current/v26.3/alter-sequence.md index 298413465a7..d8f0c36171c 100644 --- a/src/current/v26.3/alter-sequence.md +++ b/src/current/v26.3/alter-sequence.md @@ -27,7 +27,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen -----------|------------ `IF EXISTS` | Modify the sequence only if it exists; if it does not exist, do not return an error. `sequence_name` | The name of the sequence. -`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

Note that `RENAME TO` can be used to move a sequence from one database to another, but it cannot be used to move a sequence from one schema to another. To change a sequence's schema, use `ALTER SEQUENCE ...SET SCHEMA` instead. +`RENAME TO sequence_name` | Rename the sequence to `sequence_name`, which must be unique to its database and follow these [identifier rules]({% link {{ page.version.version }}/keywords-and-identifiers.md %}#identifiers). Name changes do not propagate to the table(s) using the sequence.

`RENAME TO` only changes the name of the sequence; it cannot move the sequence to a different database or schema. To change a sequence's schema, use `ALTER SEQUENCE ... SET SCHEMA` instead. `CYCLE`/`NO CYCLE` | The sequence will wrap around when the sequence value reaches the maximum or minimum value. `CYCLE` is not implemented. If `NO CYCLE` is set, the sequence will not wrap. `OWNED BY column_name` | Associates the sequence to a particular column. If that column or its parent table is dropped, the sequence will also be dropped.

Specifying an owner column with `OWNED BY` replaces any existing owner column on the sequence. To remove existing column ownership on the sequence and make the column free-standing, specify `OWNED BY NONE`.

**Default:** `NONE` `CACHE` | The number of sequence values to cache in memory at the [node]({% link {{ page.version.version }}/architecture/overview.md %}#node) level. All sessions on the node share the same cache, which can be concurrently accessed, and which reduces the chance of creating large gaps between generated IDs. A cache size of `1` means that there is no cache, and cache sizes of less than `1` are not valid.

**Default:** `1` (sequences are not cached by default). While this parameter caches sequences per node, to cache sequence values per session, use [`PER SESSION CACHE`](#per-session-cache) explicitly. @@ -115,55 +115,6 @@ In this example, we will change the name of sequence. (1 row) ~~~ -### Change the database of a sequence - -In this example, we will move the sequence we renamed in the first example (`even_sequence`) from `defaultdb` (i.e., the default database) to a different database. - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> CREATE DATABASE mydb; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> ALTER SEQUENCE even_sequence RENAME TO mydb.even_sequence; -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM defaultdb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- -(0 rows) -~~~ - -{% include_cached copy-clipboard.html %} -~~~ sql -> SHOW SEQUENCES FROM mydb; -~~~ - -~~~ - sequence_schema | sequence_name -------------------+---------------- - public | even_sequence -(1 row) -~~~ - ### Change the schema of a sequence Suppose you [create a sequence]({% link {{ page.version.version }}/create-sequence.md %}) that you would like to add to a new schema called `cockroach_labs`: diff --git a/src/current/v26.3/alter-table.md b/src/current/v26.3/alter-table.md index 006ae83ba7e..fea77dadc29 100644 --- a/src/current/v26.3/alter-table.md +++ b/src/current/v26.3/alter-table.md @@ -446,7 +446,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. #### Parameters diff --git a/src/current/v26.3/alter-view.md b/src/current/v26.3/alter-view.md index e1164e40934..b14d157f06d 100644 --- a/src/current/v26.3/alter-view.md +++ b/src/current/v26.3/alter-view.md @@ -80,7 +80,7 @@ WITH x AS (SHOW TABLES) SELECT * FROM x WHERE type = 'view'; (1 row) ~~~ -Note that `RENAME TO` can be used to move a view from one database to another, but it cannot be used to move a view from one schema to another. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). In a future release, `RENAME TO` will be limited to changing the name of a view, and will not have the ability to change a view's database. +Note that `RENAME TO` only changes the name of the view; it cannot move the view to a different database or schema. To change a view's schema, [use the `SET SCHEMA` clause](#change-the-schema-of-a-view). ### Change the schema of a view From c9059451e3134ac6e514f4922a27c505acda586c Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Mon, 8 Jun 2026 01:45:55 -0400 Subject: [PATCH 3/4] v26.3: ALTER TABLE/VIEW/SEQUENCE ... RENAME TO checks CREATE on the schema Starting in v26.3, `ALTER TABLE/VIEW/SEQUENCE ... RENAME TO` requires the `CREATE` privilege on the relation's schema instead of on its database, matching PostgreSQL. `DROP` on the relation is still required. Mark the change with a "New in v26.3" tag on the affected pages. Refs: https://github.com/cockroachdb/cockroach/issues/171478 Co-Authored-By: roachdev-claude --- src/current/v26.3/alter-sequence.md | 2 +- src/current/v26.3/alter-table.md | 2 +- src/current/v26.3/alter-view.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/current/v26.3/alter-sequence.md b/src/current/v26.3/alter-sequence.md index d8f0c36171c..6cfad9e38bc 100644 --- a/src/current/v26.3/alter-sequence.md +++ b/src/current/v26.3/alter-sequence.md @@ -13,7 +13,7 @@ The `ALTER SEQUENCE` [statement]({% link {{ page.version.version }}/sql-statemen - To alter a sequence, the user must be the owner of the sequence. - To change the schema of a sequence with `ALTER SEQUENCE ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the new schema. -- To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's database. +- {% include_cached new-in.html version="v26.3" %} To rename a sequence with `ALTER SEQUENCE ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the sequence and the `CREATE` privilege on the sequence's schema. ## Syntax diff --git a/src/current/v26.3/alter-table.md b/src/current/v26.3/alter-table.md index fea77dadc29..01a63c8d6ca 100644 --- a/src/current/v26.3/alter-table.md +++ b/src/current/v26.3/alter-table.md @@ -446,7 +446,7 @@ For examples, see [Rename tables](#rename-tables). #### Required privileges -The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` on the parent database. +{% include_cached new-in.html version="v26.3" %} The user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the table and the `CREATE` privilege on the table's schema. #### Parameters diff --git a/src/current/v26.3/alter-view.md b/src/current/v26.3/alter-view.md index b14d157f06d..407eb953cbf 100644 --- a/src/current/v26.3/alter-view.md +++ b/src/current/v26.3/alter-view.md @@ -11,9 +11,9 @@ The `ALTER VIEW` [statement]({% link {{ page.version.version }}/sql-statements.m ## Required privileges -- To alter a view, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. - To set or reset `security_invoker`, the user must own the view. -- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, or to change the name of a view with `ALTER VIEW ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view. +- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the new schema. +- {% include_cached new-in.html version="v26.3" %} To rename a view with `ALTER VIEW ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the view's schema. ## Syntax From f3193d2534347cedd0f28a5138fb3f6cc0337468 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Mon, 8 Jun 2026 01:45:58 -0400 Subject: [PATCH 4/4] Fix ALTER VIEW required privileges for v23.1 through v26.2 The ALTER VIEW pages stated that altering a view requires `CREATE` on the parent database, and that `SET SCHEMA` and `RENAME TO` additionally require `DROP` on the view. Verified against a running v24.3 server: - `SET SCHEMA` requires `DROP` on the view and `CREATE` on the new schema, not `CREATE` on the parent database. - `RENAME TO` requires `DROP` on the view and `CREATE` on the view's database. - The standalone "must have `CREATE` on the parent database" bullet described no single operation on its own, so it is removed. This brings the ALTER VIEW privilege model in line with ALTER TABLE and the corrected ALTER SEQUENCE pages. The v26.3 page documents the schema-scoped rename privilege separately. Co-Authored-By: roachdev-claude --- src/current/v23.1/alter-view.md | 4 ++-- src/current/v23.2/alter-view.md | 4 ++-- src/current/v24.1/alter-view.md | 4 ++-- src/current/v24.2/alter-view.md | 4 ++-- src/current/v24.3/alter-view.md | 4 ++-- src/current/v25.1/alter-view.md | 4 ++-- src/current/v25.2/alter-view.md | 4 ++-- src/current/v25.3/alter-view.md | 4 ++-- src/current/v25.4/alter-view.md | 4 ++-- src/current/v26.1/alter-view.md | 4 ++-- src/current/v26.2/alter-view.md | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/current/v23.1/alter-view.md b/src/current/v23.1/alter-view.md index 8f23021bd5f..e5481a33573 100644 --- a/src/current/v23.1/alter-view.md +++ b/src/current/v23.1/alter-view.md @@ -11,8 +11,8 @@ The `ALTER VIEW` [statement]({% link {{ page.version.version }}/sql-statements.m ## Required privileges -- To alter a view, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, or to change the name of a view with `ALTER VIEW ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view. +- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the new schema. +- To rename a view with `ALTER VIEW ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the view's database. ## Syntax diff --git a/src/current/v23.2/alter-view.md b/src/current/v23.2/alter-view.md index 8f23021bd5f..e5481a33573 100644 --- a/src/current/v23.2/alter-view.md +++ b/src/current/v23.2/alter-view.md @@ -11,8 +11,8 @@ The `ALTER VIEW` [statement]({% link {{ page.version.version }}/sql-statements.m ## Required privileges -- To alter a view, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, or to change the name of a view with `ALTER VIEW ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view. +- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the new schema. +- To rename a view with `ALTER VIEW ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the view's database. ## Syntax diff --git a/src/current/v24.1/alter-view.md b/src/current/v24.1/alter-view.md index 298b0f1f2b7..2735d9112e3 100644 --- a/src/current/v24.1/alter-view.md +++ b/src/current/v24.1/alter-view.md @@ -11,8 +11,8 @@ The `ALTER VIEW` [statement]({% link {{ page.version.version }}/sql-statements.m ## Required privileges -- To alter a view, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, or to change the name of a view with `ALTER VIEW ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view. +- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the new schema. +- To rename a view with `ALTER VIEW ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the view's database. ## Syntax diff --git a/src/current/v24.2/alter-view.md b/src/current/v24.2/alter-view.md index 298b0f1f2b7..2735d9112e3 100644 --- a/src/current/v24.2/alter-view.md +++ b/src/current/v24.2/alter-view.md @@ -11,8 +11,8 @@ The `ALTER VIEW` [statement]({% link {{ page.version.version }}/sql-statements.m ## Required privileges -- To alter a view, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, or to change the name of a view with `ALTER VIEW ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view. +- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the new schema. +- To rename a view with `ALTER VIEW ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the view's database. ## Syntax diff --git a/src/current/v24.3/alter-view.md b/src/current/v24.3/alter-view.md index 298b0f1f2b7..2735d9112e3 100644 --- a/src/current/v24.3/alter-view.md +++ b/src/current/v24.3/alter-view.md @@ -11,8 +11,8 @@ The `ALTER VIEW` [statement]({% link {{ page.version.version }}/sql-statements.m ## Required privileges -- To alter a view, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, or to change the name of a view with `ALTER VIEW ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view. +- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the new schema. +- To rename a view with `ALTER VIEW ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the view's database. ## Syntax diff --git a/src/current/v25.1/alter-view.md b/src/current/v25.1/alter-view.md index 298b0f1f2b7..2735d9112e3 100644 --- a/src/current/v25.1/alter-view.md +++ b/src/current/v25.1/alter-view.md @@ -11,8 +11,8 @@ The `ALTER VIEW` [statement]({% link {{ page.version.version }}/sql-statements.m ## Required privileges -- To alter a view, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, or to change the name of a view with `ALTER VIEW ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view. +- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the new schema. +- To rename a view with `ALTER VIEW ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the view's database. ## Syntax diff --git a/src/current/v25.2/alter-view.md b/src/current/v25.2/alter-view.md index 298b0f1f2b7..2735d9112e3 100644 --- a/src/current/v25.2/alter-view.md +++ b/src/current/v25.2/alter-view.md @@ -11,8 +11,8 @@ The `ALTER VIEW` [statement]({% link {{ page.version.version }}/sql-statements.m ## Required privileges -- To alter a view, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, or to change the name of a view with `ALTER VIEW ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view. +- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the new schema. +- To rename a view with `ALTER VIEW ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the view's database. ## Syntax diff --git a/src/current/v25.3/alter-view.md b/src/current/v25.3/alter-view.md index 298b0f1f2b7..2735d9112e3 100644 --- a/src/current/v25.3/alter-view.md +++ b/src/current/v25.3/alter-view.md @@ -11,8 +11,8 @@ The `ALTER VIEW` [statement]({% link {{ page.version.version }}/sql-statements.m ## Required privileges -- To alter a view, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, or to change the name of a view with `ALTER VIEW ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view. +- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the new schema. +- To rename a view with `ALTER VIEW ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the view's database. ## Syntax diff --git a/src/current/v25.4/alter-view.md b/src/current/v25.4/alter-view.md index 298b0f1f2b7..2735d9112e3 100644 --- a/src/current/v25.4/alter-view.md +++ b/src/current/v25.4/alter-view.md @@ -11,8 +11,8 @@ The `ALTER VIEW` [statement]({% link {{ page.version.version }}/sql-statements.m ## Required privileges -- To alter a view, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, or to change the name of a view with `ALTER VIEW ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view. +- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the new schema. +- To rename a view with `ALTER VIEW ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the view's database. ## Syntax diff --git a/src/current/v26.1/alter-view.md b/src/current/v26.1/alter-view.md index 298b0f1f2b7..2735d9112e3 100644 --- a/src/current/v26.1/alter-view.md +++ b/src/current/v26.1/alter-view.md @@ -11,8 +11,8 @@ The `ALTER VIEW` [statement]({% link {{ page.version.version }}/sql-statements.m ## Required privileges -- To alter a view, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. -- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, or to change the name of a view with `ALTER VIEW ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view. +- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the new schema. +- To rename a view with `ALTER VIEW ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the view's database. ## Syntax diff --git a/src/current/v26.2/alter-view.md b/src/current/v26.2/alter-view.md index 3d69be40b50..d89bb5aeae3 100644 --- a/src/current/v26.2/alter-view.md +++ b/src/current/v26.2/alter-view.md @@ -11,9 +11,9 @@ The `ALTER VIEW` [statement]({% link {{ page.version.version }}/sql-statements.m ## Required privileges -- To alter a view, the user must have the `CREATE` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the parent database. - To set or reset `security_invoker`, the user must own the view. -- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, or to change the name of a view with `ALTER VIEW ... RENAME TO`, the user must also have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view. +- To change the schema of a view with `ALTER VIEW ... SET SCHEMA`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the new schema. +- To rename a view with `ALTER VIEW ... RENAME TO`, the user must have the `DROP` [privilege]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) on the view and the `CREATE` privilege on the view's database. ## Syntax