create synonym syno1 for test.tab1;
select * from syno1;
※MySQLにシノニムはない
--データベースに一括で別名を付与するプロシージャがある。
(5.7)
http://sakaik.hateblo.jp/entry/20170126/mysql_synonym_db
基のスキーマ内のすべての表およびビューを参照するビューを持つシノニムスキーマが作成されます
call sys.create_synonym_db('performance_schema', 'p_s');
call sys.create_synonym_db('test', 't');
show databases;
select table_schema, table_name, table_type FROM information_schema.tables;
※PostgreSQLにシノニムはない。
ビューで似たようなことは可能
create role user11 with superuser createdb createrole login encrypted password 'user11';
create role user12 with superuser createdb createrole login encrypted password 'user12';
create schema schema11 authorization user11;
create schema schema12 authorization user12;
--user11
set search_path = schema11;
create table tab1(col1 int);
insert into tab1 values(1);
insert into tab1 values(2);
insert into tab1 values(3);
create view schema12.tab1 as select * from schema11.tab1;
grant select on schema12.tab1 to user12;
--user12
set search_path = schema12;
select * from tab1;
USE test;
GO
CREATE SYNONYM syno1
FOR test.dbo.tab1;
GO