oracle create a sequence & Index & view

 

--- oracle learning

  --oracle learning management system
  --oracle learning data management
  user management --oracle of
  --oracle two-dimensional table management
  --oracle knowledge of other
    sequences --oracle, views, indexes
    --oracle paging query
    - the oracle database backup
    --oracle graphical interface operation

 

 

sequence

1  - a sequence of learning oracle 
2      - Creating a Sequence 
3        - Use create sequence sequence name 
4        - Feature 1: The default start is no value, that is, the pointer finger in a position of no value. 
5        - Feature 2: sequence name .nextval will increment once each execution, default step is 1 
6        - Features 3: sequence name .currval view the current value of the sequence. Start is not. 
. 7        - effect: as the primary key, the values between the dynamic acquisition, this new data is avoided when a great primary key violation 
. 8             - using .nextval sequence name as the primary key 
. 9        - Note: non-null primary key can be the only, primary key value need not be continuous value. 
10             - Creating a default sequence 
11               the Create Sequence CC; - create a sequence CC 
12               the SELECT cc.currval from Dual -View the current value of the sequence 
13               the SELECT cc.nextval from Dual - View from increased value of the sequence. 
14             - create a custom sequence of 
15                Create Sequence AA - creating a sequence 
16                Start with  . 5       - set start position 
. 17                INCREMENT by  2     - setting step 
18 is            Cache 10           - Cache 10 
. 19                SELECT aa.currval from Dual 
 20 is                SELECT AA .nextval from Dual
 21         - create test table
22            create table teacher(
23                 tid number(10) primary key,
24                 tname varchar(100) not null
25            )
26            insert into teacher values(cc.nextval,'张三');
27            insert into teacher values(cc.nextval,'张三');
28             
29            select * fromTeacher
 30      - Delete sequence 
31             - drop Sequence Sequence name 
32             drop Sequence AA
View Code

 

index

1       - Role: improve query efficiency 
2       - Use Index: 
3           - created 
4             the Create  index index name on table name (field name)
 5           - remove the index 
6             drop  index index name
 7       - Features: 
8           - display create, implicit execution 
9       - Note: 
10           - the Oracle automatically creates an index to the table's primary key. 
11        
12       the Create  index index_teacher_tname ON Teacher (tname) - creating the index 
13       drop  index index_teacher_tname -Delete Index 
14       SELECT  *  from Teacher WHERE tname = ' John Doe ' 
15       SELECT  *  from Teacher WHERE TID = . 8
View Code

 

view

1  - View Learning: 
2        - Use the view: 
3            - Create a view 
4            the Create  View view name AS  the SELECT content provided externally from the real table name
 5            - Delete view 
6            drop  View view name
 7        - view features: 
8           - - Feature 1: protection real table, hide important data fields. Protect data. 
9           - Feature 2: Operation will perform mapping in the view of the real table 
10           - Feature 3: You can manually turn on read-only mode uses only the Read keyword with 
11        - Note: Create the view must have dba privileges 
12        the Create  View STU AS  the SELECT sno,sname,sage from  bjsxt.student
13       create view stu2 as select sno,sname,sage from  student with read only 
14       drop view stu
15       select * from student
16       select * from stu
17       update stu2 set sname='wollo' where sno=1
18       grant dba to bjsxt
View Code

 

Guess you like

Origin www.cnblogs.com/jiefangzhe/p/11514786.html