Contents Index Using the WITH CHECK OPTION clause Deleting views

ASA SQL User's Guide
  Working with Database Objects
    Working with views

Modifying views


You can modify a view using both Sybase Central and Interactive SQL. When doing so, you cannot rename an existing view directly. Instead, you must create a new view with the new name, copy the previous code to it, and then delete the old view.

In Sybase Central, you can edit the code of views, procedures, and functions on the object's SQL tab in the right pane. You edit a view in a separate window by right-clicking the view and choosing Edit In New Window from the popup menu. In Interactive SQL, you can use the ALTER VIEW statement to modify a view. The ALTER VIEW statement replaces a view definition with a new definition, but it maintains the permissions on the view.

For more information on altering database object properties, see Setting properties for database objects.

For more information on setting permissions, see Granting permissions on tables and Granting permissions on views. For information about revoking permissions, see Revoking user permissions.

To edit a view definition (Sybase Central)

  1. Open the Views folder.

  2. Select the desired view.

  3. In the right pane, click the SQL tab and edit the view's code.

    Tip 
    If you wish to edit multiple views, you may wish to open separate windows for each view rather than editing each view on the SQL tab in the right pane. You can open a separate window by right-clicking a view and choosing Edit In New Window from the popup menu.

To edit a view definition (SQL)

  1. Connect to a database with DBA authority or as the owner of the view.

  2. Execute an ALTER VIEW statement.

Example 

Rename the column names of the DepartmentSize view (described in the Creating views section) so that they have more informative names.

ALTER VIEW DepartmentSize
  (Dept_ID, NumEmployees)
AS
  SELECT dept_ID, count(*)
  FROM Employee
  GROUP BY dept_ID

For more information, see ALTER VIEW statement.


Contents Index Using the WITH CHECK OPTION clause Deleting views