PL/SQL Code authoring rules

Source: Internet
Author: User

1. Naming rules for identifiers
When you use identifiers in PL/SQL to define variables, constants, the identifier name must begin with a character and cannot exceed 30 characters in length. In addition, to improve the readability of the program, Oracle recommends that users define various identifiers according to the following rules:
(1) When defining variables, it is recommended to use v_ as a prefix, such as V_sal, V_job, and so on.
(2) When defining constants, it is recommended to use C_ as a prefix, such as c_rate.
(3) When defining cursors, it is recommended to use _cursor as a suffix, such as emp_cursor.
(4) When defining an exception, it is recommended to use E_ as a prefix, such as E_integrity_error.
(5) When defining a PL/SQL table type, it is recommended to use _table_type as a suffix, such as sal_table_type.
(6) When defining a PL/SQL table variable, it is recommended to use _table as a suffix, such as sal_table.
(7) When defining a PL/SQL record type, it is recommended to use _record_type as a suffix, such as emp_record_type.
(8) When defining a PL/SQL record variable, it is recommended to use _record as a suffix, such as Emp_record.

2. Casing Rules
When you write an SQL statement and a PL/SQL statement in a PL/LC block, the statement can either use uppercase or lowercase. However, in order to improve the readability and performance of the program, Oracle recommends that the user be encoded in the following casing rules:
(1) The SQL keyword in uppercase format, such as SELECT, UPDATE, SET, where and so on.
(2) PL/SQL keywords in uppercase format, such as DECLARE, BEGIN, end, etc.
(3) data type in uppercase format, such as INT, varchar2,date, etc.
(4) Identifiers and parameters in lowercase format, such as V_sal, c_rate, etc.
(5) Database objects and columns in lowercase format, such as EMP, Sal, ename and so on.

This article from "It Technology Learning and communication" blog, declined reprint!

PL/SQL Code authoring rules

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.