Best Practice in SQL
1) Avoid searching based on concatenation
Select * from employee where empno || name = ’1234qiao’
Select * from employee where empno=1234 and name = ’qiao’
2) It is advisable to put the table that returns the fewest rows at the end of the From list.
Select * from table1, table2
Table1 – contains 10000, Table2 – contains 100
3) If more than one table is used in a query, then it is advisable to use table aliases, as it would enhance the speed of parse phase of the query.
4) Avoid using NOT or != operators, it causes full table scan.
5) Using EXISTS instead of IN when the selective filters are in parent query.
6) Using IN instead of EXISTS when the selective filters are in sub query.