diff --git a/mint.json b/mint.json index bf9781b8..714db63d 100644 --- a/mint.json +++ b/mint.json @@ -467,6 +467,8 @@ "sql/commands/sql-alter-schema", "sql/commands/sql-alter-sink", "sql/commands/sql-alter-source", + "sql/commands/sql-alter-subscription", + "sql/commands/sql-alter-swap", "sql/commands/sql-alter-system", "sql/commands/sql-alter-table", "sql/commands/sql-alter-user", diff --git a/sql/commands/sql-alter-materialized-view.mdx b/sql/commands/sql-alter-materialized-view.mdx index 484490e9..356c46dc 100644 --- a/sql/commands/sql-alter-materialized-view.mdx +++ b/sql/commands/sql-alter-materialized-view.mdx @@ -63,7 +63,7 @@ SET PARALLELISM = parallelism_number; | Parameter or clause | Description | | :-------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **SET PARALLELISM** | This clause controls the degree of [parallelism](/reference/key-concepts#parallelism) for the targeted [streaming job](/reference/key-concepts#streaming-jobs). | +| **SET PARALLELISM** | This clause controls the degree of [parallelism](/reference/key-concepts#parallelism) for the targeted [streaming job](/reference/key-concepts#streaming-queries). | | _parallelism\_number_ | This parameter can be ADAPTIVE or a fixed number, like 1, 2, 3, etc. Altering the parameter to ADAPTIVE will expand the streaming job's degree of parallelism to encompass all available units, whereas setting it to a fixed number will lock the job's parallelism at that specific figure. Setting it to 0 is equivalent to ADAPTIVE. | ```sql @@ -112,3 +112,21 @@ ALTER MATERIALIZED VIEW mv1 SET BACKFILL_RATE_LIMIT=DEFAULT; To modify the rate limit of the sources used in the materialized view, please refer to [SET SOURCE_RATE_LIMIT](/sql/commands/sql-alter-source#set-source-rate-limit). + +### `SWAP WITH` + +```sql +ALTER MATERIALIZED VIEW name +SWAP WITH target_name; +``` + +| Parameter | Description | +| :-------- | :---------- | +| _name_ | The current name of the materialized view to swap. | +| _target_name_ | The target name of the materialized view you want to swap with. | + +```sql +-- Swap the names of the sales_summary materialized view and the sales_archive materialized view. +ALTER MATERIALIZED VIEW sales_summary +SWAP WITH sales_archive; +``` \ No newline at end of file diff --git a/sql/commands/sql-alter-sink.mdx b/sql/commands/sql-alter-sink.mdx index f042e92a..5bdbcef5 100644 --- a/sql/commands/sql-alter-sink.mdx +++ b/sql/commands/sql-alter-sink.mdx @@ -63,7 +63,7 @@ SET PARALLELISM = parallelism_number; | Parameter or clause | Description | | :-------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **SET PARALLELISM** | This clause controls the degree of [parallelism](/reference/key-concepts#parallelism) for the targeted [streaming job](/reference/key-concepts#streaming-jobs). | +| **SET PARALLELISM** | This clause controls the degree of [parallelism](/reference/key-concepts#parallelism) for the targeted [streaming job](/reference/key-concepts#streaming-queries). | | _parallelism\_number_ | This parameter can be ADAPTIVE or a fixed number, like 1, 2, 3, etc. Altering the parameter to ADAPTIVE will expand the streaming job's degree of parallelism to encompass all available units, whereas setting it to a fixed number will lock the job's parallelism at that specific figure. Setting it to 0 is equivalent to ADAPTIVE. | ```sql @@ -87,3 +87,21 @@ ALTER SINK sink_name -- Change the name of the sink named "sink0" to "sink1" ALTER SINK sink0 RENAME TO sink1; ``` + +### `SWAP WITH` + +```sql +ALTER SINK name +SWAP WITH target_name; +``` + +| Parameter | Description | +| :-------- | :---------- | +| _name_ | The current name of the sink to swap. | +| _target_name_ | The target name of the sink you want to swap with. | + +```sql +-- Swap the names of the log_sink sink and the error_sink sink. +ALTER SINK log_sink +SWAP WITH error_sink; +``` \ No newline at end of file diff --git a/sql/commands/sql-alter-source.mdx b/sql/commands/sql-alter-source.mdx index 05216969..91d5c47e 100644 --- a/sql/commands/sql-alter-source.mdx +++ b/sql/commands/sql-alter-source.mdx @@ -188,3 +188,21 @@ ALTER SOURCE kafka_source SET source_rate_limit TO default; -- Alter the rate limit of a source to 1000 ALTER SOURCE kafka_source SET source_rate_limit TO 1000; ``` + +### `SWAP WITH` + +```sql +ALTER SOURCE name +SWAP WITH target_name; +``` + +| Parameter | Description | +| :-------- | :---------- | +| _name_ | The current name of the source to swap. | +| _target_name_ | The target name of the source you want to swap with. | + +```sql +-- Swap the names of the api_data source and the file_data source. +ALTER SOURCE api_data +SWAP WITH file_data; +``` \ No newline at end of file diff --git a/sql/commands/sql-alter-subscription.mdx b/sql/commands/sql-alter-subscription.mdx new file mode 100644 index 00000000..f22d262a --- /dev/null +++ b/sql/commands/sql-alter-subscription.mdx @@ -0,0 +1,101 @@ +--- +title: "ALTER SUBSCRIPTION" +description: "The `ALTER SUBSCRIPTION` command modifies the definition of a subscription." +--- + +## Syntax + +```sql +ALTER SUBSCRIPTION subscription_name + alter_option; +``` + +`alter_option` depends on the operation you want to perform on the subscription. For all supported clauses, see the sections below. + +## Clauses + +### `OWNER TO` + +```sql +ALTER SUBSCRIPTION current_subscription_name + OWNER TO new_user; +``` + +| Parameter or clause | Description | +| :------------------ | :---------------------------------------------- | +| **OWNER TO** | This clause changes the owner of the subscription. | +| _new\_user_ | The new owner you want to assign to the subscription. | + +```sql +-- Change the owner of the subscription named "sub" to user "admin" +ALTER SUBSCRIPTION sub OWNER TO admin; +``` + +### `RENAME TO` + +```sql +ALTER SUBSCRIPTION subscription_name + RENAME TO new_name; +``` + +| Parameter or clause | Description | +| :------------------ | :----------------------------------------- | +| **RENAME TO** | This clause changes the name of the subscription. | +| _new\_name_ | The new name of the subscription. | + +```sql +-- Rename the subscription named "sub0" to "sub1" +ALTER SUBSCRIPTION sub0 RENAME TO sub1; +``` + +### `SET PARALLELISM` + +```sql +ALTER SUBSCRIPTION subscription_name +SET PARALLELISM = parallelism_number; +``` + +| Parameter or clause | Description | +| :-------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **SET PARALLELISM** | This clause controls the degree of [parallelism](/reference/key-concepts#parallelism) for the targeted [streaming job](/reference/key-concepts#streaming-queries). | +| _parallelism\_number_ | This parameter can be ADAPTIVE or a fixed number, like 1, 2, 3, etc. Altering the parameter to ADAPTIVE will expand the streaming job's degree of parallelism to encompass all available units, whereas setting it to a fixed number will lock the job's parallelism at that specific figure. Setting it to 0 is equivalent to ADAPTIVE. | + +```sql +-- Set the parallelism of the SUBSCRIPTION "s" to 4. +ALTER SUBSCRIPTION s SET PARALLELISM = 4; +``` + +### `SET SCHEMA` + +```sql +ALTER SUBSCRIPTION current_subscription_name + SET SCHEMA schema_name; +``` + +| Parameter or clause | Description | +| :------------------ | :-------------------------------------------------------- | +| **SET SCHEMA** | This clause moves the subscription to a different schema. | +| _schema\_name_ | The name of the schema to which the subscription will be moved. | + +```sql +-- Move the subscription named "test_subscription" to the schema named "test_schema" +ALTER SUBSCRIPTION test_subscription SET SCHEMA test_schema; +``` + +### `SWAP WITH` + +```sql +ALTER SUBSCRIPTION name +SWAP WITH target_name; +``` + +| Parameter | Description | +| :-------- | :---------- | +| _name_ | The current name of the subscription to swap. | +| _target_name_ | The target name of the subscription you want to swap with. | + +```sql +-- Swap the names of the user_updates subscription and the admin_updates subscription. +ALTER SUBSCRIPTION user_updates +SWAP WITH admin_updates; +``` \ No newline at end of file diff --git a/sql/commands/sql-alter-swap.mdx b/sql/commands/sql-alter-swap.mdx new file mode 100644 index 00000000..a3388b15 --- /dev/null +++ b/sql/commands/sql-alter-swap.mdx @@ -0,0 +1,30 @@ +--- +title: "ALTER SWAP" +--- + +The `ALTER ... SWAP` command enables the exchange of names between two database objects, such as tables, materialized views, views, sources, sinks, or subscriptions. It simplifies the process of renaming two objects by allowing them to be swapped in a single operation. + + +The objects being swapped must be of the same type; otherwise, an error will be returned. + + +## Syntax + +```sql +ALTER [ TABLE | MATERIALIZED VIEW | VIEW | SOURCE | SINK | SUBSCRIPTION ] name +SWAP WITH target_name; +``` + +## Parameter + +| Parameter | Description | +| :-------- | :---------- | +| _name_ | The current name of the database object to swap. | +| _target_name_ | The target name of the database object you want to swap with. | + +## Example + +```sql +ALTER MATERIALIZED VIEW historical_sales +SWAP WITH current_sales; +``` \ No newline at end of file diff --git a/sql/commands/sql-alter-table.mdx b/sql/commands/sql-alter-table.mdx index d4281352..9f428ab3 100644 --- a/sql/commands/sql-alter-table.mdx +++ b/sql/commands/sql-alter-table.mdx @@ -10,7 +10,7 @@ ALTER TABLE table_name alter_option; ``` -_`alteroption`_ depends on the operation you want to perform on the table. For all supported clauses, see the sections below. +alter_option depends on the operation you want to perform on the table. For all supported clauses, see the sections below. ## Clauses @@ -108,7 +108,7 @@ SET PARALLELISM = parallelism_number; | Parameter or clause | Description | | :-------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **SET PARALLELISM** | This clause controls the degree of [parallelism](/reference/key-concepts#parallelism) for the targeted [streaming job](/reference/key-concepts#streaming-jobs). | +| **SET PARALLELISM** | This clause controls the degree of [parallelism](/reference/key-concepts#parallelism) for the targeted [streaming job](/reference/key-concepts#streaming-queries). | | _parallelism\_number_ | This parameter can be ADAPTIVE or a fixed number, like 1, 2, 3, etc. Altering the parameter to ADAPTIVE will expand the streaming job's degree of parallelism to encompass all available units, whereas setting it to a fixed number will lock the job's parallelism at that specific figure. Setting it to 0 is equivalent to ADAPTIVE. After setting the parallelism, the parallelism status of a table can be observed within the internal [rw\_table\_fragments](/operate/view-configure-runtime-parameters) table or the [rw\_fragments](/operate/view-configure-runtime-parameters)table. | ```sql @@ -167,6 +167,24 @@ SELECT fragment_id, parallelism FROM rw_fragments; (2 rows) ``` +### `SWAP WITH` + +```sql +ALTER TABLE name +SWAP WITH target_name; +``` + +| Parameter | Description | +| :-------- | :---------- | +| _name_ | The current name of the table to swap. | +| _target_name_ | The target name of the table you want to swap with. | + +```sql +-- Swap the names of the products table and the inventory table. +ALTER TABLE products +SWAP WITH inventory; +``` + ### `RENAME TO` ```sql diff --git a/sql/commands/sql-alter-view.mdx b/sql/commands/sql-alter-view.mdx index a3cdb06c..2e229577 100644 --- a/sql/commands/sql-alter-view.mdx +++ b/sql/commands/sql-alter-view.mdx @@ -10,7 +10,7 @@ ALTER VIEW view_name alter_option; ``` -_`alteroption`_ depends on the operation you want to perform on the view. For all supported clauses, see the sections below. +`alter_option` depends on the operation you want to perform on the view. For all supported clauses, see the sections below. ## Clause @@ -64,3 +64,21 @@ ALTER VIEW view_name -- Change the name of the view named "view1" to "view2" ALTER VIEW view1 RENAME TO view2; ``` + +### `SWAP WITH` + +```sql +ALTER VIEW name +SWAP WITH target_name; +``` + +| Parameter | Description | +| :-------- | :---------- | +| _name_ | The current name of the view to swap. | +| _target_name_ | The target name of the view you want to swap with. | + +```sql +-- Swap the names of the user_profiles view and the guest_profiles view. +ALTER VIEW user_profiles +SWAP WITH guest_profiles; +```