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
One: The value of the field of the query string type is NOT NULL for SQL:[SQL]View Plaincopy
SELECT * from tb_cms_flgtinfo_a t where (T.fsta are not null and t.fsta ');
Main: The above tb_cms_flgtinfo_a is the table name, Fsta is the field in the tableTwo: The query string Type field has a null value f
String sql= "SELECT * FROM (select E.*,rownum r from (SELECT * to emp ORDER BY sal Desc) e) where r between? and? ";String sql= "SELECT * FROM (select E.*,rownum r from (SELECT * to emp ORDER BY sal Desc) e) where r between 6 and 10";StringBuilder vs = new StringBuilder ();Vs.append ("SELECT * FROM (");Vs.append ("Select E.*, RowNum RNO from (SELECT * from emp ORDER BY sal Desc) e");Vs.append (")");Vs.appen
operation is the same as in 1, and the merge into method is recommended if you make a decision. Because merge into accesses only one emp_new1.
Iii. Deleting delete operations
1. Delete duplicate records:
There are many kinds of methods, here only one, using the analysis function grouping, determine whether the group number is greater than 1.
Delete from emp where rowid in (select Rid from (select rowID as RIDs, row_num
In Oracle, SQL queries table information because the data structure design of some modules of the project is not strictly in accordance with a certain specification design, it can only beTo query the data structure, you need to query the following information: field name, data type, whether it is null, default value, p
Oracle multi-Table query, as its name implies, queries the data you want from multiple tables. Here we will test the emp table and dept table under the scott user. The structure of the two tables is as follows:SQL> select * from dept;DEPTNO DNAME LOC-------------------------------------10 ACCOUNTING NEW YORK20 RESEARCH DALLAS30 SALES CHICAGO40 OPERATIONS BOSTON
SQL
Query all the elements of a distance from a certain point (that is, the surrounding query) SQL:
Select T. objectid, T. comp_type, T. datatype, T. comp_name, T. health_lic, T. shape. sdo_point.x as x, t. shape. sdo_point.y as Y, T. reg_addr, T. bus_addr from t_publicplaces t where 1 = 1 and substr (T. comp_type,) = '01' and sdo_within_distance (T. shape, sdo_geom
[SQL] Three Methods of Oracle paging Query use the pseudo column rownum to query the first 10 records
[SQL] select * from t_user t where ROWNUM
[Note] 1.
where rownum>1Records cannot be captured. 2.
where rownum between 2 and 10And cannot capture records. Use the analysis f
1 query statement 1.1 obtain the unique record -- distinct obtain the employee's unique salary status SQL statement is as follows. SQLgt; selectdistincte. employee_name,
1 query statement 1.1 obtain the unique record -- distinct obtain the employee's unique salary status SQL statement is as follows. SQLgt; select disti
">
2. Merge into statement:
For the top statement, you can use the merge into statement
--Merge into implementation method
merge into EMP
using (SELECT * from
emp_new1
) E on
(e.empno = emp.empno)
when matched then
update set emp.empdesc = E.empdesc;The execution results are the same as the results in 1, assuming inference. It is recommended to use the merge into method.
Because merge into only visits once emp_new1.
Iii. Deleting delete op
Oracle Query result set, random sort
Copy Code code as follows:
SELECT * FROM table1 ORDER by Dbms_random.value ();
MySQL randomly query out a record:
Copy Code code as follows:
--The following query statement is efficient, do not use SELECT * FROM table1 to rand () LIMIT to
Preface
The best way to learn is practice! Therefore, my learning is based on practice. The most basic SQL statement is the query statement. Therefore, I also learned from the select statement. (In fact, this part of the author) has been mastered, but it is still necessary to grasp it again.
For the previous study, we mainly used some existing tables in the Oracle
One of the Oracle-SQL skills (query continuous records) Requirement Description: www.2cto.com needs to query that a customer has been continuously performing business for those days of a year. The SQL implementation is as follows: Create a table: create table test_num (tyear
Label:1.oracle querying the number of tables in the database:Select COUNT (*) from User_tablesThe premise of this operation is that the login is successful2.mysql querying the number of tables in the database:SELECT COUNT (*) TABLES, table_schema from INFORMATION_SCHEMA. TABLES WHERE table_schema = ' database ' GROUP by Table_schema;Change the database three words to the name of their corresponding databaseQuery the number of tables in a data in 3.sql
I. Query recently executed SQL statementsSelect SQL _text, last_load_time from v $ SQL order by last_load_time desc;SELECT SQL _text, last_load_time FROM v $ SQL WHERE last_load_time is not null and
The following articles mainly introduce Oracle SQL queries. Oracle SQL queries are widely used in a short period of time because of their unique functions. The following articles will provide you with relevant knowledge. Hope you will have some gains.
Common SQL queries:
1.
SQL statement for querying and deleting duplicate records1. Search for redundant duplicate records in the Table. duplicate records are determined based on a single field (peopleid ).Select * from peopleWhere peopleid in (select peopleid from people group by peopleid having count (peopleid)> 1)2. Delete unnecessary duplicate records in the Table. Repeat records are determined based on a single field (eagleid), leaving only the records with the smallest
SELECT statements in Oracle can use the start with ... Connect by prior clause implements recursive query, connect by is used in structured query, its basic syntax is:
Copy Code code as follows:
SELECT * FROM tablename start with Cond1
Connect by Cond2
where Cond3;
In short, a tree structure is stored in a table, for example, there are tw
My SQL is very poor, half a day response to, was a colleague joke. Oh, ah ah. Must surpass him later!!Table ShopPk_shop PRIMARY KeyName Commodity
Shop
Pk_shop
Name
001
Down
002
Coca - cola
Bpm_ll_test2
PK_BPM_LL_TEST2 PRIMARY Key
Sname Product Name
01
001
Select (select name from shop where shop s s.pk_shp
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.