Skip to content

Add support for RENAME TABLE and table synonyms#165

Merged
yfuruyama merged 1 commit intocloudspannerecosystem:masterfrom
takabow:feature/support-table-rename
Mar 12, 2024
Merged

Add support for RENAME TABLE and table synonyms#165
yfuruyama merged 1 commit intocloudspannerecosystem:masterfrom
takabow:feature/support-table-rename

Conversation

@takabow
Copy link
Copy Markdown
Contributor

@takabow takabow commented Mar 12, 2024

This PR includes This PR adds support for the following, related to the recently added table rename feature in Spanner.

  • RENAME TABLE support

Examples:

spanner> SHOW TABLES;
+----------------------+
| Tables_in_example-db |
+----------------------+
| Album                |
+----------------------+
1 rows in set (0.03 sec)

spanner> ALTER TABLE Album RENAME TO AlbumDetails, ADD SYNONYM Album;
Query OK, 0 rows affected (12.66 sec)

spanner> SHOW TABLES;
+----------------------+
| Tables_in_example-db |
+----------------------+
| Album                |
| AlbumDetails         |
+----------------------+
2 rows in set (0.02 sec)

spanner> RENAME TABLE AlbumDetails TO AlbumDetails2;
Query OK, 0 rows affected (9.58 sec)

spanner> SHOW TABLES;
+----------------------+
| Tables_in_example-db |
+----------------------+
| Album                |
| AlbumDetails2        |
+----------------------+
2 rows in set (0.02 sec)

@takabow
Copy link
Copy Markdown
Contributor Author

takabow commented Mar 12, 2024

The current behavior of SHOW TABLES displays both tables and views from INFORMATION_SCHEMA.TABLES. To match this behavior, synonyms are also displayed. If necessary, we may adopt the SHOW FULL TABLE syntax from MySQL.

spanner> SHOW TABLES;
+----------------------+
| Tables_in_example-db |
+----------------------+
| Album                |    # Synonym
| AlbumDetails         |    # Renamed table
+----------------------+
2 rows in set (0.02 sec)

@takabow takabow force-pushed the feature/support-table-rename branch from 5e95c1f to 91ed00e Compare March 12, 2024 06:13
Copy link
Copy Markdown
Collaborator

@yfuruyama yfuruyama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for adding this change!

@yfuruyama yfuruyama merged commit c70d18b into cloudspannerecosystem:master Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants