25

If I have database D1 and database D2, and table T1 under database D1 and table T2 under database D2, is it possible to create a view of T1 under database D2 in MySQL. If so, can you show me the syntax.

Bot databases are on the same machine.

Marcello Romani
  • 2,967
  • 31
  • 40
Ank
  • 6,040
  • 22
  • 67
  • 100

1 Answers1

45
CREATE VIEW `D2`.`example` AS SELECT * FROM `D1`.`T1`;
jnrbsn
  • 2,498
  • 1
  • 18
  • 25
  • 3
    how is that doable if you have different user for each database? do we need to GRANT view to the 'viewing' user? I need to do that but i'm not just there yet. edit: precision -> same host, different users. – Louis Loudog Trottier Feb 04 '17 at 08:53
  • how can I select particular fileds with this? `SELECT D1.T1.F1`? – vladkras Jan 29 '18 at 19:41