Summary: in this tutorial, you will learn how to use the Oracle CREATE VIEW statement to create a new view in the database.

Oracle CREATE VIEW syntax

To create a new view in a database, you use the following Oracle CREATE VIEW statement:

Check the table Predefined Parameters of Namespace USERENV for the list of parameters and the expected return values. Eg., SQL column. The OR REPLACE option replaces the definition of existing view. It is handy if you have granted various privileges on the view.

2
4
CREATE[ORREPLACE]VIEWview_name[(column_aliases)]AS
[WITHREADONLY]

OR REPLACE

The OR REPLACE option replaces the definition of existing view. It is handy if you have granted various privileges on the view. Because when you use the DROP VIEW and CREATE VIEW to change the view’s definition, Oracle removes the view privileges, which may not be what you want. To avoid this, you can use the CREATE OR REPLACE clause that preserves the view privileges.

FORCE

Usually, you create a new view based on existing tables. However, sometimes, you may want to create a view based on the tables that you will create later or the tables that you don’t have sufficient privileges to access at the time of creating the view. In these cases, you can use the FORCE option.

column-aliases

Typically, the column names of a view derived from the select list of the defining query. However, the column names of the defining query may contain functions or expressions that you cannot use for the view definition.

To solve this problem, you have two options:

  • Use column aliases that adhere to the naming rules in the SELECT clause of the defining query.
  • Explicitly specify column aliases for the view’s columns between the CREATE VIEW and AS clauses.

AS defining-query

Parametros estadisticos

The defining query is a SELECT statement that defines the columns and rows of the view.

WITH READ ONLY

The WITH READ ONLY clause prevents the underlying tables from changes through the view.

WITH CHECK OPTION

The WITH CHECK OPTION clause protects the view from any changes to the underlying table that would produce rows which are not included in the defining query.

Oracle CREATE VIEW examples

Let’s look at some examples of creating new views based on the tables in the sample database.

A) Creating a view example

See the following employees table from the sample database.

The following statement creates a view named employee_yos based on the employees table. The view shows the employee id, name and years of service:

2
4
6
SELECT
first_name ' ' last_namefull_name,
FLOOR(months_between(CURRENT_DATE,hire_date)/12)yos
employees;

In this example, we did not define the column names for the view because the defining query uses column aliases for expressions such as full_name for first_name ' ' last_name and yos for FLOOR( months_between( CURRENT_DATE, hire_date )/ 12 ).

If you don’t want to use column aliases in the query, you must define them in the CREATE VIEWclause:

2
4
6
CREATEVIEWemployee_yos(employee_id,full_name,yos)AS
employee_id,
FLOOR(months_between(CURRENT_DATE,hire_date)/12)
employees;

The following query returns employees whose years of service are 15:

2
4
6
8
*
employee_yos
yos=15
full_name;

B) Creating a read-only view example

Consider the following customers table:

The following example creates a read-only view named customer_credits, which is based on the customers table. The view contains three columns: customer id, customer name and credit limit:

2
4
6
8
10
customer_id,
credit
SELECT
name,
FROM

C) Creating a Join view example

A join view is a view whose defining query contains a join, e.g., inner join or left join. The following statement creates a view named backlogs whose the defining query includes join clauses that join three tables: orders, order_items, and products.

2
4
6
8
10
12
14
16
18
20
22
24
SELECT
EXTRACT(
FROM
)YEAR,
FROM
INNERJOINorder_items
INNERJOINproducts
WHERE
GROUPBY
YEAR
order_date
product_name;

In this tutorial, you have learned how to use the Oracle CREATE VIEW statement to create new views in the database.

8i 9i 10g 11g 12c 13c 18c 19c Misc PL/SQL SQL RAC WebLogic Linux

Home » Articles » 11g » Here

The Automatic Workload Repository (AWR) was introduced in Oracle 10g and included some simple baseline functionality. Creating a baseline allowed a specified range of snapshots to be retained, regardless of the AWR retention policy, and used for performance comparisons. This functionality, and the DBMS_WORKLOAD_REPOSITORY package that manages it, has been extended in Oracle 11g.

Most of the procedures and functions in the DBMS_WORKLOAD_REPOSITORY package accept a DBID parameter, which defaults to the local database identifier. For that reason the following examples will omit this parameter.

Related articles.

Fixed Baselines

The fixed, or static, baseline functionality is a little more flexible in Oracle 11g compared to that of Oracle 10g. Originally, the DBMS_WORKLOAD_REPOSITORY package included a single CREATE_BASELINE procedure allowing you to define baselines using specific snapshot IDs. It now includes overloaded procedures and functions allowing baselines to be created using start and end times, which are used to estimate the relevant snapshot IDs. The functions have the same parameter lists as the procedures, but return the baseline ID. By default baselines are kept forever, but the new expiration parameter allows them to be automatically expired after a specified number of days.

The new baselines are visible in DBA_HIST_BASELINE view.

Information about a specific baseline can be displayed by using the BASELINE_ID with the SELECT_BASELINE_DETAILS pipelined table function, or the BASELINE_NAME with the SELECT_BASELINE_METRIC pipelined table function.

Baselines are renamed using the RENAME_BASELINE procedure.

Baselines are dropped using the DROP_BASELINE procedure.

Enterprise Manager is probably the most convenient way to manage AWR baselines. From the 'AWR Baselines' screen (Server > AWR Baselines), click the 'Create' button.

Select the interval type of 'Single' and click the 'Continue' button.

Enter a name for the baseline and mark the start and end of the baseline by either clicking on the snapshot icons or entering the time range manually, then click the 'Finish' button.

The newly created baseline is now displayed in the 'AWR Baselines' screen.

The baseline is renamed or dropped by checking its 'Select' box and clicking the 'Edit' or 'Delete' button respectively. Once the baseline is created you can schedule statistics computation by checking its 'Select' box, selecting 'Schedule Statistics Computation' in the drop down list, then clicking 'Go' button.

The Moving Window Baseline

Oracle 11g introduces the concept of a moving window baseline, which is used to calculate metrics for the adaptive thresholds. The window is a view of the AWR data within the retention period. The default size of the window matches the default AWR retention period of 8 days, but it can be set as a subset of this value. Before you can increase the size of the window you must first increase the size of the AWR retention period.

The current AWR retention period can be displayed by querying the RETENTION column of the DBA_HIST_WR_CONTROL view.

The retention period is altered using the MODIFY_SNAPSHOT_SETTINGS procedure, which accepts a RETENTION parameter in minutes.

The current moving window size is displayed by querying the DBA_HIST_BASELINE view.

The size of the moving window baseline is altered using the MODIFY_BASELINE_WINDOW_SIZE procedure, which accepts a WINDOW_SIZE parameter in days.

Oracle recommend of window size greater than or equal to 30 days when using adaptive thresholds.

To adjust the retention periods in Enterprise Manager, click on the 'Edit' button in the 'Automatic Workload Repository' screen (Server > Automatic Workload Repository).

Edit the 'Use Time-Based Retention' to the appropriate number of days and click the 'OK' button.

Next, navigate to the 'AWR baselines' screen (Server > AWR Baselines), select the 'SYSTEM_MOVING_WINDOW' baseline and click the 'Edit' button.

Set the appropriate 'Window Size' and click the 'Apply' button.

Baseline Templates

Baseline templates allow you to define baselines you would like to capture in the future. Overloads of the CREATE_BASELINE_TEMPLATE procedure define the capture of individual baselines, or repeating baselines. Creating a single baseline template is similar to creating a time-based baseline, except the time is in the future.

Templates for repeating baselines are a little different as they require some basic scheduling information. The START_TIME and END_TIME parameters define when the template is activated and deactivated. The DAY_OF_WEEK, HOUR_IN_DAY and DURATION parameters define the day (MONDAY - SUNDAY or ALL) the baselines are generated on and the start and end point of the baseline. Since the template will generate multiple baselines, the baseline name is derived from the BASELINE_NAME_PREFIX concatenated to the date. The following example creates a template that will run for the next six months, gathering a baseline every Monday between 00:00 and 05:00.

Information about baseline templates is displayed using the DBA_HIST_BASELINE_TEMPLATE view.

Notice the BASELINE_NAME_PREFIX column holds either the prefix or full baseline name depending on the type of baseline being captured.

Baseline templates are dropped using the DROP_BASELINE_TEMPLATE procedure.

Enterprise Manager uses the same screens for creating single baseline templates as it does for creating baselines. Navigate to the 'AWR Baselines' screen (Server > AWR Baselines) and click the 'Create' button.

Select the interval type of 'Single' and click the 'Continue' button.

Enter a name for the baseline template and mark the start and end of the baseline by entering the time range manually, then click the 'Finish' button. If the time range is in the future, a baseline template is automatically created, rather than a regular baseline.

To view the baseline template, click the 'AWR Baseline Templates' link at the bottom of the 'AWR baselines' screen.

To creating the repeating baseline templates, start the baseline creation as before, but select the interval type of 'Repeating' and click the 'Continue' button.

Enter the baseline name prefix, which is also used as the template name, along with the interval and scheduling details, then click the 'Finish' button.

MYOB Accounting Plus v18 ED is an application released by the software company MYOB Technology Pty Ltd. Frequently, users want to erase it. Sometimes this is troublesome because doing this manually takes some skill regarding Windows internal functioning. MYOB Accounting Plus v18 18.0. Choose the most popular programs from Business software. 3.4 (69 votes) 18.0. Free download myob v18 software; Best general-purpose software. NetBeans IDE. 4k YouTube to MP3. Synology Data Replicator. Visual Prolog. Sebelum menggunakan program MYOB, maka kita harus menginstall softwarenya terlebih dahulu. Jika kalian belum punya softwarenya, bisa di download di link berikut ini: DOWNLOAD MYOB V.18 ED Ukuran: 123 MB CARA INSTALL: Buka file AccountingPlus18 yang tadi telah di download Klik 2x pada file setup.exe, dan klik Next terus sampai proses intallasi. Download myob v18 ed

Once again, the baseline template is visible on the 'AWR Baseline Templates' screen.

Baseline Metric Thresholds

Oracle 11g simplifies the definition of metric thresholds by allowing them to be applied to baselines, including the moving window baseline. The easiest way to start using baseline metric thresholds is to click the 'Quick Configuration' button on the 'Baseline Metric Thresholds' screen (Home > Baseline Metric Thresholds).

Select the relevant 'Workload Profile' for your system, then click the 'Continue' button.

Click the 'Finish' button on the review screen.

The adaptive thresholds are then visible on the 'Baseline Metric Thresholds' screen. Click the category name or 'Edit Threshold' icon to edit the threshold settings.

If you need to amend the threshold settings, remember to click the 'Apply Thresholds' button once you have finished.

For more information see:

Hope this helps. Regards Tim..