Overview of parameterized secure views in Cloud SQL

Parameterized secure views in Cloud SQL for MySQL provide data security and row access control to applications while supporting SQL. These views support data value extraction—the process of retrieving specific data pieces from columns—and they help protect against prompt injection attacks. Parameterized secure views help ensure that end users can view only the data that they are supposed to access.

Parameterized secure views are an extension of MySQL views, which let you use application-specific named view parameters in view definitions. This capability provides an interface that takes a query and values for the named parameters. The views execute the query with those values, which are used throughout the execution of that query.

Parameterized secure view example

The following example shows how to create a parameterized secure view on a table by adding a session variable to the WHERE clause.

-- Create a view with a parameter

CREATE VIEW v_orders AS
SELECT * FROM orders
WHERE customer_id = @local_customer_id AND year >=