diff --git a/src/current/v23.1/alter-sequence.md b/src/current/v23.1/alter-sequence.md index e6718e72d1e..5131a2e63dd 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 @@ -26,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) @@ -112,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..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 @@ -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 e6718e72d1e..5131a2e63dd 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 @@ -26,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) @@ -112,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..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 @@ -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 e6718e72d1e..5131a2e63dd 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 @@ -26,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) @@ -112,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..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 @@ -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 e6718e72d1e..5131a2e63dd 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 @@ -26,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) @@ -112,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..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 @@ -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 e6718e72d1e..5131a2e63dd 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 @@ -26,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) @@ -112,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..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 @@ -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 e6718e72d1e..5131a2e63dd 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 @@ -26,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) @@ -112,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..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 @@ -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 e6718e72d1e..5131a2e63dd 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 @@ -26,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) @@ -112,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..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 @@ -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 689d5c52c8b..6d9c26a961c 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 @@ -26,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. @@ -114,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..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 @@ -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 4d83a5302f6..bcc9dbc0214 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 @@ -26,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. @@ -114,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..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 @@ -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 4d83a5302f6..bcc9dbc0214 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 @@ -26,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. @@ -114,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..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 @@ -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 4d83a5302f6..bcc9dbc0214 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 @@ -26,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. @@ -114,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..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 @@ -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 8087e472752..6cfad9e38bc 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. +- {% 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 @@ -26,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. @@ -114,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..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. When moving a table from one database to another, the user must have the `CREATE` privilege on both the source and target databases. +{% 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 e1164e40934..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 @@ -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