oracle create a student elective view

1, conceptual view: A view is a logical structure itself contains no data, is a named select statement.
   Underlying data can be seen through the view, but the view and data are independent of each other.
2, DBA authority is required to create the view.
3,语法:CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW view[(alias[,alias]..)]
   AS subquery;
4, create or replace view showing exist when replaced;
Such as:
SQL> create view testview3
  2  as 
  3  select * from test3;
The view has been created.
 
The SQL> Create View testview3
  2 AS 
  . 3 SELECT * from Test3;
Create View testview3
            *
Line 1 Error:
ORA-00955: name is already existing object using

Modify the view:
SQL> create or replace view testview3
  2  as
  3  select * from test3;
The view has been created.
5, force represents the force does not exist if the table to create a view;
Such as: the SQL> Create View TT
  2 AS
  . 3 SELECT * from TT;
Create View TT
            *
Line 1 Error:
ORA-01731: circular view definition appears

SQL> create force view tt
  2  as
  3  select * from tt;
Warning: The views created with compilation errors.
6, see the view structure:
SQL> desc testview3;
 whether the name is null type?
 --------------------------------------- - -------- ----------------------------
 ID NUMBER the NOT NULL (38 is)
 LNAME VARCHAR2 (20 is)
 FNAME VARCHAR2 (20)

7, the view is created using a polymerization function, you need to develop an alias;
The SQL> Create View testview4
  2 AS 
  3 SELECT ID, SUM (ID) from Test3
  . 4 by Group ID;
SELECT ID, SUM (ID) from Test3
          *
error occurs line 3:
ORA-00998: column alias name must use this expression

SQL> create view testview4
  2  as
  3  select id,sum(id) test3_id from test3
  4  group by id;
The view has been created.
 
8, updated view:
SQL> select * from testview5;
  TEST5_ID TEST5_NAME           TEST5_FNAME
---------- -------------------- --------------------
         3 kong                 sales
         2 hh
SQL> update testview5 set test5_name='kong_gai'
  2  where test5_id=3;
1 line has been updated.
SQL> select * from testview5;
  TEST5_ID TEST5_NAME           TEST5_FNAME
---------- -------------------- --------------------
         3 kong_gai             sales
         2 hh
 
Description link

Guess you like

Origin www.cnblogs.com/sunny3158/p/11315981.html