Oracle practice -- synonyms and sequences of PL/SQL Basics

Source: Internet
Author: User

Synonyms and sequences of PL/SQL Basics

PL/SQL: a programming Language combined with a Structured Language (Structured Query Language). It is an extension of SQL and supports multiple data types, such as large objects and Collection types, you can use control statements such as conditions and loops to create stored procedures, packages, and triggers, and add program logic to SQL statement execution, tightly integrated with Oracle servers and Oracle tools, it is portable, flexible, and secure.

Synonym:

/*

Synonym: an alias of an existing object;

Advantages: 1. Simplified SQL; 2. Hiding the Object Name and owner; 3. providing public access to the object

*/

-- Create a private synonym, which can only be accessed in the mode and cannot be the same as the current object

create or replace synonym em for emp;select *from em;drop synonym em;

-- Create a public Synonym that can be accessed by all database users. Of course, other users must have access permissions.

create or replace synonym em for emp;select *from em;drop synonym em;

/*

Sequence: an object used to generate a unique and continuous sequence number. It can be in ascending or descending order.

*/

create or replace synonym em for emp;select *from em;drop synonym em;

-- Query Sequence

Select my_seq.nextval from dual; -- next value of the sequence select my_seq.currval from dual; -- create table person (pid number primary key, pname varchar2 (20 ))

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.