CREATE VIEW

    The optional clause causes the view to be replaced if it already exists rather than raising an error.

    In the default DEFINER security mode, tables referenced in the view are accessed using the permissions of the view owner (the creator or definer of the view) rather than the user executing the query. This allows providing restricted access to the underlying tables, for which the user may not be allowed to access directly.

    Regardless of the security mode, the current_user function will always return the user executing the query and thus may be used within views to filter out rows or otherwise restrict access.

    Create a simple view over the orders table:

    Create a view that replaces an existing view:

    drop-view,