Question

I have a view in database B which I use in database A.

I would like to create a synonym to this view. Because right now each time I have to write the query like this

Select * from DBNAME.VIEWNAME

rather I just want to be able to write

SELECT * FROM MYSYNONYMNAME

Is that possible to do in mysql? I didn't see much in the manual..

Was it helpful?

Solution

It's not possible to create synonyms in mysql like it's possible in Oracle

OTHER TIPS

Apparently a VIEW may work as a SYNONYM:

DROP VIEW IF EXISTS `MYSYNONYMNAME` $$
CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER VIEW `MYSYNONYMNAME` AS
SELECT * FROM DBNAME.VIEWNAME $$

Not sure of performance or how far you can get away stacking views within views etc. Also might need to recreate when base table columns change.

See: http://blog.mclaughlinsoftware.com/2013/11/24/mysql-synonym/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top