How can I edit a view in MySQL Workbench without it auto prefixing a database name to the tables/views used -
when create view, create in context of default database. none of references table have prefix explicitly specify database. however, when edit view in workbench automatically adds database prefix!
i don't want database prefix because when restore database under different name causes restore fail.
is possible stop prefixing in view edit or there way round restore issue?
regards,
bobbyy
that's not possible. views stored in specific databases, not in space "above" databases. consider following...
use playground_a; /*or whatever database*/ create view view_whatever select * table_whatever; use playground_b; select * view_whatever; /*here error view_whatever not exist*/ select * playground_a.view_whatever; /*this works*/
that's why there database prefixes in view definition.
the possibility see, use stored procedure database name parameter. in procedure you'd use prepared statement execute concated string of query , database name parameter. of course comes downsides, i.e. can't add clause easily.
Comments
Post a Comment