When we write SQL statements, we often ignore some details. The following is a summary of my own operations and materials. If there is something wrong, or there is a supplement.
When we write SQL statements, we often ignore some details. The following is a summary of my own operations and materials. If there is something wrong, or there is a supplement.
When we write SQL statements, we often ignore some details. The following is a summary of my own operations and materials. If there is something wrong or something wrong, hope to reply to me and learn from each other. Thank you!
1. When a full table scan is performed, and the number of records in the full table scan is more than 100, you need to create a correspondingIndexOrChange query ConditionsTo use index queries to avoid full table scans.
2. Use the like statement in the query as much as possible.Suffix fuzzy search. For example:
Select * from tablename where column_name like'% Name %'-- The index on column_name is not used
Select * from tablename where column_name like' Name %' -- Use the index on column_name
3. If the subquery or list after in contains more than five values, do not use in instead of exists; use not exists instead of not in.
4. Do not select useless fields.
For more information about Oracle, see the Oracle topic page? Tid = 12