MBA in Finance, Marketing | Master in Computers | Commerce Graduate | Oracle Technologist | an Analyst | Data Scientist | Pythonista | Chess aficionado | Shutter-bug | Yoga enthusiast | Professional Portfolio | Personal Profile
- 66,715 hits since Jul 2011
Join 37 other subscribers
His Blog Calendar
Did you know?There is a search engine that plants trees - “www.ecosia.org”. Another search engine that saves energy. "Blackle.com - Saving energy one search at a time". A given monitor requires more power to display a white (or light) screen than a black (or dark) screen.
Other posts by him
Tag CloudArt of Living DBA OCP Oracle OTN PLSQL Sattva Spiritual Sri Sri Ravi Shankar vijay.mahawar
Oracle User Groups
BBC Tech News
- Twitch apologises as streamers leave after adverts row
- TikTok: ByteDance accused of helping China spy on Hong Kong activists
- BBC, BA and Boots issued with ultimatum by cyber gang Clop
- 'Ducking hell' to disappear from Apple autocorrect
- MoveIt hack: What action can data-breach victims take?
- Vision Pro: Apple's new augmented reality headset unveiled
- US sues Coinbase as crypto crackdown widens
- Microsoft to pay $20m for child privacy violations
- MOVEit hack: BBC, BA and Boots among cyber attack victims
- Linda Yaccarino replaces Elon Musk as Twitter boss
All content provided in this blog is for informational purposes only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site.
The owner will not be liable for any errors or omissions in this information nor for the availability of this information.
The owner will not be liable for any losses, injuries, or damages from the display or use of this information. The opinions expressed here represent his own and not those of his employer.
Best Practices for Oracle Developers: Comments
Comments are text embedded within SQL statements and PL/SQL code which describes the purpose of the code. Comments improve the readability, usability and maintenance of the code. Proper comment and formatting can save lot of hours of unproductive work for developers and teams.
Oracle developers can use two types of comments – In Line and Multiline. Both Inline and Multiline comments can be used in SQL statements and PL/SQL.
In-Line comments starts with — (two hyphens) and is only limited to one line.
Multiline comments start with /* and ends with */ and spans multiple lines.
Oracle uses following comment styles for its standard scripts (scripts under – $oracle_home/rdbms/admin directory) which are shipped with oracle database.
In many oracle shipped sql scripts you will see REM commands (REMARK command). This can also be used to enhance the readability and maintenance of the sql scripts. A sample snippet from the mksample.sql is shown below:
In my PL/SQL programs I use multi-line comment style like below:
Oracle allows to store comments even for schema objects like table and views and on columns of table, views and materialized views. These comments provide useful information about the table and columns to other developers.
To insert an explanatory remark on the
notescolumn of the EMP table, you might issue the following statement:
The comments defined in this way are stored in data dictionary views.
Object comments are stored in USER_TAB_COMMENTS
Column comments are stored in USER_COL_COMMENTS
To drop this comment from the database, issue the following statement:
Please use setup scripts and demo script script for this.
Note: Few minutes spent on proper comments can save hours of efforts in code maintenance and debug.
Posted by Viju on 1 March, 2014 in Oracle, PL/SQL
Tags: demobld.sql, mksample.sql, multi-line comments, PL/SQL comments, REMARK command, single line comments, SQL comments