View and index of Oracle Practice--PL/SQL Foundation

Source: Internet
Author: User
Tags create index dname

A view and index of the start of PL/SQL basics


PL/sql: Process language (Procedure Language) and structured language (structured Query Language)The combination of the programming language, is theSQLextensions that support multiple data types, such as large objects and collection types, can use control statements such as conditions and loops to create stored procedures, packages, triggers, and so on, toSQLthe execution of the statement adds program logic, andOracleservers, andOracletools are tightly integrated, with portability, flexibility, and security.

-----------------------------------------------------------------------------------------------------

View:

/*

View: Displays data from one or more tables in a way that is developed

can be considered a " virtual table " or " stored query "

The table on which the view is created is the base table

Advantages:1. provides an additional level of security ;

2. the complexity of hiding data ;

3. simplify the user's SQL statement ;

4. changes in the isolation base table

5. provide access to the data from another angle by renaming the column.

*/

--piercing view, keyword view as

Create or Replace view Emp_view  --to have the view permission as select  ename,sal,dname from emp,dept where Emp.deptno = dept.de Ptno;

-- querying from the view

SELECT * from Emp_view;

-- Delete a view

Drop View Emp_view;

/*

A connection view query is similar to a multi-table join query because views can be treated as virtual tables with only a few limitations:

1. only one underlying base table can be modified

2. You cannot update a view if you modify a constraint that violates the base table

3. If the view contains a join operator,DISTINCT keyword, set operator, aggregate function, or GROUP by clause, the view cannot be updated

4. If the view contains pseudo-columns or expressions, you will not be able to update the view

*/

--------------------------------------------------------------------------------------------------------------- --

Index:

/*

Index: Index is an optional structure associated with a table

advantages of Creating an index: 1. reduce the disk I/O

2. can improve the execution ability of query statement

Note: Creating unnecessary indexes can result in performance overhead for writing data and wasted disk space

*/

--1. Create a standard index

CREATE INDEX Emp_index on EMP (ename);--note that you cannot use or Replacealter index Emp_index rebuild;--to Refactor indexes Drop INDEX emp_index;--Delete indexes

-- Create a unique index

Create unique index Dept_uniqueindex on dept (dname);d ROP unique index dept_uniqueindex;

Article Source: http://blog.csdn.net/ysjian_pingcx/article/details/25646251

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.