Oracle database objects

Source: Internet
Author: User
This article studies the usage of Oracle database objects. Oracle contains five database objects: alias, sequence, view, index, and cluster. the alias and sequence are specific database objects in Oracle.

Alias: After setting an alias for an ORACLE data table, you can use the alias to perform the same operations on the data table as the original table name. The statement keyword isSynonym, See the specific usage.
Create synonym: Create synonym student for Stu;
After being created, student is the alias of the stu table. Therefore, the execution results of the following two statements are the same.
Select * from student; ==> select * from Stu;
Delete synonym: Drop synonym student;

Sequence:As a special object of Oracle, sequence is used to realize auto-increment of the primary key of Oracle, which is different from other relational databases. Keyword:Sequence.
Sequence creation method: CreateSequenceNumseq IncrementBy1Start1Maxvalue999; create a sequence to increase from 1 to 1 and set the maximum value to 999.
Sequence usage: insert into testtable values (numseq. nextval );
Nextval returns the next available value;
To obtain the value of the current sequence, you must first return a nextval value for the first time.CurrVal value.
Alter sequence alter sequence definition: Alter sequence numseq set maxvalue 1000;

Views and indexes:Its usage is the same as that of other databases.

Cluster:Two or more tables have the same columns. The same columns are stored in one space to save space.
Cluster creation method:
Create cluser classcluser
(
Classno varchar2 (10)
);
Create index cluserindex on cluser classcluser for the cluster;

Create a table stuclass and point to the defined Cluster
Create Table stuclass
(
Classno varchar2 (10 ),
Classname varchar2 (20)
) Cluser classcluser (classno );

Create a table student and point to the defined Cluster
Create Table student
(
Stuno int,
Classno varchar2 (10)
) Cluser classcluser (classno );

 

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.