Ank Ank - 2 months ago 6
MySQL Question

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.

Both the databases are on the same machine.

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