Information for: DEVELOPERS   PARTNERS

Using MySQL views

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


Views in MySQL should not be confused with the Drupal module Views, which became part of Drupal core in Drupal 8.

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 server-specific DEFINER clauses from MySQL views that remain in place if you export the database using mysqldump.

To create a mysqldump command that removes server-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 more information about backing up databases in Cloud Platform, see Backing up your application.

For additional troubleshooting information about MySQL views, see MySQL views in Cloud Platform.