Learn about sql query tuning techniques in oracle, we have the largest and most updated sql query tuning techniques in oracle information on alibabacloud.com
No matter what database I use, duplicate data exists. Next I will introduce in detail various methods and Performance Analysis for deleting duplicate records in Oracle tables, for more information, see.
Method:
The Code is as follows:
Copy code
Group by XX having count (*)> 1, rowid, distinct, temporary table, procedure
The following statement can query the data that is duplic
Tags: bracket ROM query SQL statement from Ora reason here sqlFor example: SELECT ename, Job, Deptno from emp WHERE Deptno in (Ten) NB sp; and (ename like '%I ' or job like '%er '); The executes the SQL with the following result set: 1 jones manager NBS P 2 clark manager Remove the upper sq l parentheses in the
Inner joins (inner join).
Outer joins:
Fully connected (full join), left join (left join), right join.
Cross join (cross join).
An outer join is not the same as an inner join, and the query results returned by an outer join contain not only rows that qualify, but also the left table (left outer join), the right table (the right outer join), or all the data rows in the two join tables (all outer joins) that are not eligible.
1. Left-side [outer] Join
A
Use this SQL statement
select * from tree
View the raw data as follows:
The following figure shows the result of a tree query (including the fields root, level, is_leaf, and Path ):
Execute the following SQL statement:
select connect_by_root(child_col) root, level , decode(connect_by_isleaf,0,'No',1,'Yes') is_leaf, sys_connect_by_path(child_col,'/') pathfrom
------------------------1. Simple SQL query--------------------------SELECT * from EMP;Select Empno,ename,job from EMP;Select ' number is: ' | | Empno | | ' Name is: ' | | Ename from EMP;Select distinct empno, ename from EMP;Select empno,ename,job,sal*100 Income from EMP;------------------------2. Limit query --------------------------SELECT * FROM EMP where sal>
Scalar Query
Oracle allows a single-row subquery to be included in the select clause. Using scalar queries can effectively improve performance. When using external connections or using aggregate functions, we can consider the possibility of scalar quantum queries.
1. Cancel the use of external connections
External Connection practices:Select a. username, count (*) from all_users A, all_objects B
Where a. Us
In the Where clause, you can use the Like clause with wildcards to select columns of the datetime, char, and varchar field types... "Data records. The following are available wildcard characters:% Zero or multiple characters_ Any single character (underline)Special characters[] Characters in a certain range, such as [0-9] or [aeth][^] Characters out of a certain range, such as [^ 0-9] or [^ aeth]SQL provides four matching modes for conditions:1, %: re
The syntax of SQL fuzzy query is"Select column from table where column like 'pattern ';".SQL provides four matching modes:1.% indicates any 0 or multiple characters. Statement:Select * from user where name like '% 3% ';We will find all the "three" names for "Michael", "three-legged cats", and "Tang sanzang;2. _ represents any single character. Statement:Select *
match the criteria./************************** right outer connection **/select j_c.*,j_sc.* from course j_c R join SC j_sc on j_c.cno = J_sc. CNO;650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/49/BD/wKiom1QZkUHTlxEoAAFwxqJ2Atc312.jpg "title=" Right outer connection. png "alt=" wkiom1qzkuhtlxeoaafwxqj2atc312.jpg "/>4. Full-Outer connectionFull outer joins: Returns rows that do not match the criteria in the left and right tables, in addition to and return rows that meet the criteria/
In the case of a large record, the not in query will certainly be slow and unacceptable. Like what:SELECT A.* fromWHERE A.user_id not in (SELECT B.user_id from Table_b)the best way to find it now is to check it in seconds. For example, query the DEPT_ID data with table A and b not available:SELECT A.*from tb_dept A, Tb_dept_lev BWHERE= b.dept_id (+) and is NULLThe (+) number can be understood as: + is a
My problem is as follows:
There is a table t, field c1, c2, c3, c4, which requires a random selection from the repeated values of c1 to form a result set. How to implement it?
For example, the record is as follows:
Aa1 bb1 maidAa1 bb2 cc2 dd2Aa1 bb3 cc3 dd3Aa2 bb4 cc4 dd4Aa2 bb5 cc5 dd5Aa2 bb6 cc6 dd6.....
The result is that a record is randomly selected from the value aa1, and a record is randomly selected from aa2. So on, the result set is obtained. How can I use a single
Table query:
Merge query: Use the Union keyword to remove duplicate rows that meet the criteria.
Copy Code code as follows:
Select Ename,sal,job from emp where sal > 2500 Union Select ename,sal,job from emp where job = ' MANAGER ';
The union all usage is similar to union, but does not cancel duplicate rows.
Intersect is used to take the intersection of two results.
Minus is used to
Query traversal, which needs to be stored in a hierarchical structure of data in the base table. For example, an organization is a typical example of this:
Implementation statement:
Select column
From table_name
Start with Column=value
Connect by prior Parent PRIMARY KEY = child foreign key
Example 1: In Oracle's EMP table, each record has a MGR column that uniquely identifies the current employee's empno and identifies the em
ArticleDirectory
Use pseudo-column rownum
Use analysis functions
Use minus
Use pseudo-column rownum
Query the first 10 records
Select * From t_user t where rownum
Rank the first three records by student ID
Select * from (select ID, realname from t_user order by id asc) Where rownum
Paging SQL statement, which extracts 10 records from 10th records.
Select * from (select rownum
Label:Recently, a simple study of the data paging query of oracle,mysql,sqlserver2005 has been made, and the statements of each query are posted for everyone to learn. (a), the MySQL paging query MySQL paging query is the simplest, with the help of keyword limit can be
Tags: style blog http ar color OS using SP dataOriginal: SQL Server access Oracle Query performance Problem Resolution1. Questions The system has a module that needs to query the data in the Oracle database. It is now implemented by establishing a linked server.
NUMBER
Hash value of the action that's named in the ACTION column
SERIALIZABLE_ABORTS
NUMBER
Number of times the transaction fails to serialize, producing ORA-08177 errors, totalled through all the child cursors
CPU_TIME
NUMBER
CPU time (in microseconds) used by the cursor for parsing/executing/fetching
ELAPSED_TIME
NUMBER
Elapsed time (in microseconds) used by the cursor for parsing/executing/fetching
) A. Need to display the account opening date under each customer account B. Need to display the date on which the customer placed the order C. Need to display all orders placed on a specific date D. Need to display all orders with the same release date as the order numbered 25950 8. Which of the following SELECT statements should be used if you want to display the product names in the report that cost values are higher than the average cost of all products? (B) A. Select Product name from produ
will look at examples. The following is a brief discussion of the multi-table syndication scenario. For the most visible equivalent table connection query, the CBO may generally use two connection modes nested loop and hash join (the MERGE join efficiency is less efficient than the hash join, and the general CBO will not consider it). Here, because paging is used, the maximum number of records to be returned is specified, and the NESTED loop can imme
Label:Assuming that this is page pageno, there are pagesize records per page, and now the student table is queried using MySQL, Oracle, and SQL Server paging. 1. mysql Paging query: 1 SELECT
2 *
3 from
4 student
5-1* pagesize,pagesize; Understanding: (Limit n,m) + starts from the nth line to fetch M Records, n from 0 to calculate. 2, Oracel paged
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.