Basic PL/SQL programming (8) [views, synonyms, sequences]

Source: Internet
Author: User

Concept:
A view is only a select statement, which is fully logical and non-physical. It is also called a virtual table. Secure, convenient, and consistent

Case 1: Create a view
Create or replace view myview
As
Select * from qwe;

Case 2 call View:
Select * from myview

To insert or modify a view file, you must have the corresponding permissions. Modify the view to modify the real table. The view is only select! When a view is composed of two or more tables, we cannot simultaneously operate the two tables. The read-only view with read only (with check option ), or when the restrictions include groupby and distinct (Aggregate functions), they cannot be updated.



Synonym: Sa. dept, that is, [user. Object]

Case 1: Create synonyms and delete Synonyms (unique synonyms and public synonyms ).
Create SYNONYM deptfor sa. dept -- proprietary. It takes effect only when the Creator logs on.
Drop SYNONYM dept -- delete a SYNONYM
Create publicSYNONYM dept for sa. dept -- public. All users can use this synonym.
Case 2: synonyms
Select * fromdept; -- synonym defined above


Sequence:
Concept: it is an independent transaction that can be incremented or decreased one by one. Able to control step

Case 1: Create a sequence
Create sequence kk1 -- create a sequence
Start with 1 -- the start value is 1.
Increment by 2 -- step is 2
Order -- Increment
Nocycle; -- non-circular

Case 2: Change Sequence
Alter sequence kk1 -- change the sequence
Increment by 4; -- change the Incremental Value

Case 3: Application Sequence
Select kk. nextval from dual; -- view the next value of the sequence
Select kk. currval from dual; -- view the current value of the sequence

Case 4: insert Table sequence by sequence incrementing. nextval
Insert into qwe values (kk. nextval, 'A ');
Insert into qwe values (kk. nextval, 'A ');
Insert into qwe values (kk. nextval, 'A ');
Insert into qwe values (kk. nextval, 'A ');
Insert into qwe values (kk. nextval, 'A ');
Insert into qwe values (kk. nextval, 'A ');
Insert into qwe values (kk. nextval, 'A ');

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.