latest Post

Coding Standards and Guidelines for Database

   

 Coding Standards and Guidelines for Database


 ANSI SQL 92 standards have to be followed for writing queries.

 Do not put order by clause in the query unless required.

 Do not encapsulate readonly database operations in transactions.

 Verify the row count when performing DELETE operation

 Use RETURN statement in stored procedures to help the calling program know whether the procedure worked properly.

 Key words should be capital. For example; SELECT, UPDATE, DELETE, INSERT, FROM, AND WHERE, etc.

 Use a stored procedure with output parameters instead of single record SELECT statements when retrieving one row of data.

 While writing a query as a string, do not put any space after single quote (‘). There should be a single space between every two words. There should not be a space between the last word and the concluding single quote (‘).

 Where multiple columns are selected, there should be a single space after every ‘,’ between two columns.

 All the major keywords should come on the new lines

 Stored procedure execution is fast when we pass parameters by position (the order in which the parameters are declared in the stored procedure) rather then by name.

 After each data modification statement inside a transaction, check for an error by testing the global variable @@ERROR

 Do not use “SELECT * FROM” type of query. If all the columns of the table are to be selected, list all columns in the SELECT in same order as they appear in the table definition.

 The number of columns in a SELECT statement should not be more than 6. The line separator should be placed in this case after the (,) of the last column of this line and a single space.

 For any new line separator, the separator should come after a single space after the last word of the line.

 Place a tab after each key word on a new line. 

About Mallikarjun A

Mallikarjun A
Recommended Posts × +

0 comments:

Post a Comment