There has been paradigm shift in the technological and scientific innovations that are happening around us. From First generation Vaccum Tubes to Latest generation of Nanotechnology, From Machine Language to High Level Programming Language, Technological innovation has made the computing devices – cheaper, faster, smaller.
The communication between the devices has seen a phenomenal growth. The volume of data produced by all this is rising exponentially. Today technology touches human lives more than ever before.
With all the technological and scientific progress happening around us we have kept our rich cultural heritage and values intact. We as humans are evolving so is the Oracle Database Product.
Over the years there have been several Oracle Database releases and version upgrades. What has remained mostly same are the best practices.
Here is the list of best practices which you can expect in my next few blog posts.
SQL and PL/SQL:
- Comments – In Line and Multi Line
- Replace Hard coded literals with Constants and move all related constants into a common package.
- Modular Approach – Split big program into generic and standalone sub-programs.
- Instrumentation whereever possible – ON/OFF as required.
- Achieve as much as poosible with SQL, to avoid context switching between SQL and PLSQLengine.
- Exception Handling – Try to handle all possible exceptions
- Avoid “Select * from”, Use fully qualified names when selecting from multiple tables
- Mention AUTHID clause, BEQUEATH clause,
- Avoid default Oracle implicit type conversion.
- Use %ROWTYPE for record types and %TYPE for variables. Avoid hardcoding VARCHAR2 length.
- Exit the program gracefully. Make sure to free up resources and memory before exiting.
- Familiarize with in-built oracle packages – Don’t write routine which is already provided by oracle.
- Show user, con_id – set timing on and many more, use spool in SQL scripts
- Ensure that the rollback scripts are ready.
- Compile objects in the order of precedene.
- Ensure you use paranthesis in expressions to override the default precedence order.
- Start with the data model and then proceed with the coding for complex SQL queries.
- Maintain test scripts/harness to test the logic and test performance.
- Use GET and SET to modify package variables.
- Use NOCOPY to copy variables by reference for performance benefits.
- Use control tables to make the code customized and generic.
- Group related privileges and grant it to a role for better manageability.
- Lock all unused user accounts and change default passwords for all default accounts
- Use seperate disks for system, sysaux; application data and Index tablespaces for better performance.
- Use comments whenever a parameter is changed – Record – date, time and changed by.
- Use seperate disks for multiplexed redo logs files in same redo log groups.
- Gather statistics using DBMS_STATS after BULK DML on tables and partitions.
- Schedule the housekeeping jobs to runs during off peak time.
- Keep oracle documents and useful links ready and handy for reference just like a bible.
In my next few blog posts, I shall showcase some of the best practices both for Developers and DBAs with the help of demo scripts.
This list is not complete and is ever evolving. It is outcome of my years of association with Oracle technology and the learnings I had taken from Oracle pundits. Its kind of survival kit for both Developers and DBAs.