1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【MySQL】別スキーマ(データベース)のテーブルを利用する

Posted at

目的

Oracleの場合、別スキーマのテーブルを利用する目的で、
パブリックシノニムを利用できる。
MySQLは、シノニムが存在しないため、別機能を利用する必要がある。

対策

ビューで代替する。

方法

  1. 対象表を全件検索するSQLに対してビュー名user_pubを定義する。

    CREATE VIEW user_pub AS SELECT * FROM user;
    
  2. ビューuser_pubに対するSELECT権限をユーザーに付与する。

    GRANT SELECT ON user_pub TO ユーザー名;
    

補足

  • MySQLでは、スキーマはデータベースと同義である。
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?