| |
SQL
Page history last edited by Eddie Awad 2 yrs ago
Best Practices:
- Use UNION ALL instead of UNION unless you want to eliminate duplicate selected rows.
- Avoid using SELECT * FROM table. Define the column names instead.
- Avoid using DISTINCT if you can tolerate having duplicate rows returned by a query.
- Don't mix LEFT and RIGHT OUTER JOIN in the same query.
- Use bind variables.
- Use SELECT... BULK COLLECT INTO ... FROM ... only when you are sure that the result set will be of a reasonable size, otherwise, use an explicit cursor and fetch with the LIMIT clause. (more...)
- Use the following query to check for existence based on a condition:
- select count(*) into l_cnt
from dual
where exists ( select NULL
from emp
where sal > 4000 );
that'll return 0 or 1. The where exists short circuts after finding the first row. (more...)
Worst Practices:
- Try to get published.
- Believe gurus instead of proving things with code.
- Use weirdo design practices that replace "obsolete" relational design.
- Try to keep your code dbms-neutral
- Put things that belong in the database, like referential integrity, into the application layer.
SQL
|
|
Tip: To turn text into a link, highlight the text, then click on a page or file from the list above.
|
|
|
Comments (0)
You don't have permission to comment on this page.