Loading...

Using MySQL views

In MySQL, views are saved queries that act as a virtual table, producing a set of results when called.

Cloud Platform supports the creation of MySQL views in databases, but databases containing views must be copied or restored using the Cloud Platform interface or the Cloud Platform API. Both the Cloud Platform interface and Cloud Platform API remove infrastructure-specific DEFINER clauses from MySQL views that remain in place if you export the database using mysqldump

To create a mysqldump command that removes infrastructure-specific DEFINER clauses, you must pass the output of mysqldump output through a stream editor, replacing the values of [SOURCE_DATABASE] and [TARGET_DATABASE] that are invalid on Cloud Platform, as displayed in the following example:

mysqldump [SOURCE_DATABASE] | LANG=C sed -e 's|^/[*]!50001 CREATE ALGORITHM=UNDEFINED [*]/|/*!50001 CREATE */|' -e '/^[/][*]!50013 DEFINER=/d' | mysql [TARGET_DATABASE]

All databases in a single Cloud Platform environment share the same username and password, but each environment in a subscription has its own username and password. For information about backing up databases in Cloud Platform and troubleshooting information about MySQL views, see Taking backups and MySQL views in Cloud Platform.

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Back to Section navigation