Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2015 December Database Design: Use Stored Procedure, Do not use Inline or Ad Hoc SQL

Database Design: Use Stored Procedure, Do not use Inline or Ad Hoc SQL

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

Sharing not a new topic, but this is an important question for all Database Professional and Software Architecture.
Almost every Database Professionals had faced the same discussion on their company that which one is a better either Stored Procedure or Inline Ad Hoc SQL.

As a Database Architecture, I suggest using only Stored Procedure. I know that some of new RDBMS versions support Ad Hoc SQL Statements very well, but still, I am with only Stored Procedure.

The truth about on using Stored Procedure instead of Inline SQL.

Once you create the Stored Procedure, you can call it anywhere, anytime and any number of times. Same Ad Hoc query you cannot use multiple times.

Using Stored Procedure, DBA can quickly troubleshoot long running queries.The DBA can quickly optimize the query without accessing application source code.
The DBA can also easily measure the Memory utilization and can tune the query accordingly.

The DBA can control what queries the application can run, what tables it can access. If the developers are writing Ad Hoc queries in their application, every time they will come to me and asking for different table access permissions.

Stored Procedure is a straightforward way to find the what kind of queries are running on my database server. For Inline SQL is quite difficult to trace and even multiple application also using the same type of Inline SQL.

Using Stored Procedure, you can easily prevent SQL Injection even with dynamic SQL. In the Inline SQL statements, the DBA has no control on the SQL Injection.

The DBA can also control many things like table data, data types, global database variables, parameters, temp variables.

The RDBMS stores query execution plans in the reserved cache area so running query frequently doesn’t require to be parsed and compiled again and again.
The RDBMS also stored frequently query results into the cache. If you are using Inline SQL, you cannot use the caching feature of RDBMS.

In the database system, table or transaction lock is a general thing, and it requires the full concentration of DBA. Imagine about Inline SQL. It is challenging to resolve this kind of issue where DBA feels difficulty in finding the multiple running transactions and their respective path/sequence.

The DBA has no control on application code so imagine that if a developer writes ” SELECT * ” in their Inline SQL. Anytime Database Schema or table structure can be change, and at that time their inline SQL Queries will fail.

Database Documentation is one of most important task and responsibility of the DBA. If we are managing all queries and requirements using Database Objects, it is very easy to generate or manage Database Level Diagram with the required details

Using Stored Procedure, DBA can handle security very well like hiding the Database Code from Application.

Dec 21, 2015Anvesh Patel
Database Theory: What is a Data Masking ?SQL Server: Script to find Estimated Finish Time of The Backup Database
Anvesh Patel
Anvesh Patel

Database Engineer

December 21, 2015 Database DesigningAnvesh Patel, database, database concept, database research and development, database standards, Database Theory, database topic, dbrnd, RDBMS
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....