Using Views - Sybase Adaptive Server IQ 12.4.2 Administration And Performance Manual

Table of Contents

Advertisement

Using views

Restrictions on
SELECT statements
CREATE VIEW DepartmentSize AS
SELECT dept_ID, count(*)
FROM employee
GROUP BY dept_ID
The information in a view is not stored separately in the database. Each time
you refer to the view, the associated
the appropriate data.
On one hand, this is good because it means that if someone modifies the
table, the information in the
employee
automatically up to date. On the other hand, complicated
may increase the amount of time SQL requires to find the correct information
every time you use the view.
To create a view in Sybase Central:
1
Connect to the database.
2
Click the Views folder for that database.
3
Double-click Add View.
4
Enter the tables and columns to be used. For instance, to create the same
view as in the SQL example shown above, enter employee and dept_ID.
5
From the File menu select Execute Script and from the File menu select
Close.
For more information, see the Sybase Central online Help.
When you use views, you need to be aware of certain restrictions, both on the
statements you can use to create them, and on your ability to insert
SELECT
into, delete from, or update them.
There are some restrictions on the
views. In particular, you cannot use an
A characteristic of relational tables is that there is no significance to the
ordering of the rows or columns, and using an
an order on the rows of the view. You can use the
subqueries, and joins in view definitions.
To develop a view, tune the
results you need in the format you want. Once you have the
right, you can add a phrase in front of the query to create the view. For example:
CHAPTER 3
Working with Database Objects
statement is executed to retrieve
SELECT
DepartmentSize
statements that you can use as
SELECT
clause in the
ORDER BY
ORDER BY
GROUP BY
query by itself until it provides exactly the
SELECT
view will be
statements
SELECT
query.
SELECT
clause would impose
clause,
query just
SELECT
129

Advertisement

Table of Contents
loading

Table of Contents