Documentation Home

26.4.4.1 create_synonym_db() 过程

给定模式名称,此过程将创建一个同义词模式,其中包含引用原始模式中所有表和视图的视图。例如,这可用于创建一个较短的名称,通过该名称来引用具有长名称(例如info而不是 INFORMATION_SCHEMA)的架构。

参数
  • in_db_name VARCHAR(64):要为其创建同义词的架构的名称。

  • in_synonym VARCHAR(64): 用于同义词模式的名称。此架构不得已存在。

例子
mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| world              |
+--------------------+
mysql> CALL sys.create_synonym_db('INFORMATION_SCHEMA', 'info');
+---------------------------------------+
| summary                               |
+---------------------------------------+
| Created 63 views in the info database |
+---------------------------------------+
mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| info               |
| mysql              |
| performance_schema |
| sys                |
| world              |
+--------------------+
mysql> SHOW FULL TABLES FROM info;
+---------------------------------------+------------+
| Tables_in_info                        | Table_type |
+---------------------------------------+------------+
| character_sets                        | VIEW       |
| collation_character_set_applicability | VIEW       |
| collations                            | VIEW       |
| column_privileges                     | VIEW       |
| columns                               | VIEW       |
...