Create a view by joining two tables : Create View « View « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » View » Create View 
8. 1. 8. Create a view by joining two tables
SQL>
SQL>
SQL> create table courses
  2  code        VARCHAR2(6)
  3  , description VARCHAR2(30)
  4  , category    CHAR(3)
  5  , duration    NUMBER(2)) ;

Table created.

SQL>
SQL>
SQL> insert into courses values('SQL','SQL course',    'GEN',4);

row created.

SQL> insert into courses values('OAU','Oracle course', 'GEN',1);

row created.

SQL> insert into courses values('JAV','Java course',   'BLD',4);

row created.

SQL> insert into courses values('PLS','PL/SQL course', 'BLD',1);

row created.

SQL> insert into courses values('XML','XML course',    'BLD',2);

row created.

SQL> insert into courses values('ERM','ERM course',    'DSG',3);

row created.

SQL> insert into courses values('PMT','UML course',    'DSG',1);

row created.

SQL> insert into courses values('RSD','C# course',     'DSG',2);

row created.

SQL> insert into courses values('PRO','C++ course',    'DSG',5);

row created.

SQL> insert into courses values('GEN','GWT course',    'DSG',4);

row created.

SQL>
SQL>
SQL>
SQL> create table course_schedule
  2  course     VARCHAR2(6)
  3  , begindate  DATE
  4  , trainer    NUMBER(4)
  5  , location   VARCHAR2(20)) ;

Table created.

SQL>
SQL>
SQL> insert into course_schedule values ('SQL',date '1999-04-12',1,'VANCOUVER' );

row created.

SQL> insert into course_schedule values ('OAU',date '1999-08-10',2,'CHICAGO');

row created.

SQL> insert into course_schedule values ('SQL',date '1999-10-04',3,'SEATTLE');

row created.

SQL> insert into course_schedule values ('SQL',date '1999-12-13',4,'DALLAS' );

row created.

SQL> insert into course_schedule values ('JAV',date '1999-12-13',5,'SEATTLE');

row created.

SQL> insert into course_schedule values ('XML',date '2000-02-03',6,'VANCOUVER' );

row created.

SQL> insert into course_schedule values ('JAV',date '2000-02-01',7,'DALLAS' );

row created.

SQL> insert into course_schedule values ('PLS',date '2000-09-11',8,'VANCOUVER' );

row created.

SQL> insert into course_schedule values ('XML',date '2000-09-18',NULL,'SEATTLE');

row created.

SQL> insert into course_schedule values ('OAU',date '2000-09-27',9,'DALLAS' );

row created.

SQL> insert into course_schedule values ('ERM',date '2001-01-15',10, NULL    );

row created.

SQL> insert into course_schedule values ('PRO',date '2001-02-19',NULL,'VANCOUVER' );

row created.

SQL> insert into course_schedule values ('RSD',date '2001-02-24',8,'CHICAGO');

row created.

SQL>
SQL>
SQL> create or replace view crs_course_schedule as
  2  select o.course as course_code, c.description, o.begindate
  3  from   course_schedule o
  4         join
  5         courses   c
  6         on (o.course = c.code);

View created.

SQL>
SQL> drop table course_schedule;

Table dropped.

SQL>
SQL> drop table courses;

Table dropped.

SQL>
SQL>
8. 1. Create View
8. 1. 1. Views
8. 1. 2. Creating and Using a View
8. 1. 3. Creating and Using Simple Views
8. 1. 4. Choose specific column from base table
8. 1. 5. Creating a View with a CHECK OPTION Constraint
8. 1. 6. Creating a View with a READ ONLY Constraint
8. 1. 7. Create view based on user-defined function
8. 1. 8. Create a view by joining two tables
8. 1. 9. Create view based on aggregate function
8. 1. 10. a user-defined type view
8. 1. 11. CREATE MATERIALIZED VIEW with TABLESPACE
8. 1. 12. CREATE MATERIALIZED VIEW with rowid
8. 1. 13. Create view by join three tables
8. 1. 14. Create view on single field of a type
8. 1. 15. create materialized view emp_dept build immediate refresh on demand enable query rewrite
8. 1. 16. Use view based on user-defind type
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.