A View Alias provides the ability to create security views on SQL Server in an alternate schema.
The View Aliases tab enables you to define additional/replica views.

FieldsDescription
Add buttonEnables you to add a View Alias which adds a new copy of the view. This enables you to define new View Alias which is an alternate definition that will ultimately exist as another database view with a different name, predicate and/or target location.
Delete buttonEnables you to delete a View Alias and remove its metadata details after closing the screen.
View Alias NameThe view alias name is used as the alternate database view name.
View Alias DescriptionDescription of the view alias.
View Alias PredicateOptional 'Where' clause to include in the alternate view definition.
Target ConnectionThe name of the WhereScape RED connection identifies the target location to create the alternate view.
Database Type[Read Only] The database type of the selected target connection.
TargetThe target that defines the database and schema for the table. Leave blank for the connection default.
Target Database[Read Only] Database Name to reference the alternate view.
Target Schema[Read Only] The target Database/User schema for the alternate view. Leave blank to use the default schema,

View Alias Through Templates

RED supports template-based Create View DDL Statement generation for view aliases.

The CREATE VIEW statement needs to reference $OBJECT$ or $DATABASE$.$SCHEMA$.$TABLE$ tokens or use template variables to explicitly form the qualified view name. You cannot use the[TABLEOWNER] markup in the create statement as it cannot be correctly replaced at run-time for each View Alias. This means your existing create view templates may need updating to work with View Aliases.

For example, use:

CREATE OR REPLACE VIEW $OBJECT$

Instead of:

CREATE OR REPLACE VIEW [TABLEOWNER].[{{table.name}}]

Additional steps to create View Aliases for template-based Create View DDL statements are the following:

  • Configure a Create View DDL Template in the view object.
  • Configure Drop View SQL in the connection.

The Default Create View DDL Template for new View Objects can be configured in the connection.

The same CREATE VIEW DDL and Drop View SQL are used for both View Objects and View Aliases.

View Aliases are not meta objects and they cannot be found when applying [TABLEOWNER] markup, but [TABLEOWNER]can still be used elsewhere in the CREATE VIEW statement such as in FROM clause when used to markup source tables.


It is also possible to branch the logic in the Create View DDL Template by inspecting a new template variable table.viewAliasParent. This variable is only defined for view aliases, so the logic can be used only for View Aliases:

{% if table.viewAliasParent is defined %} 

The table.viewAliasParent variable identifies the view object that owns the view alias.


  • No labels