Search code examples
mysqldatabaseview

Creating view across different databases


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.


Solution

  • CREATE VIEW `D2`.`example` AS SELECT * FROM `D1`.`T1`;