Oracle experiences 1 -- oracle introduction @ basic SQL statement @ conditional query @ sort data theory and case studies1. Oracle IntroductionOracle is the first word for English translation of oracle (Oracle bone inscriptions) Unearthed from Yin. Oracle is the world's largest supplier of information management software and services. It was founded in 1977 and is headquartered in Redwood shore, California.
: #0000ff" >select top 5 St. text , Qp.query_plan, Qs. * from sys.dm_exec_query_stats QS cross APPLY sys.dm_exec_sql_text (qs.plan_handle) St cross APPLY sys.dm_exec_query_plan (qs.plan_handle) QP order by total_worker_time desc go you can see here that I used a simple ORDER by Total_worker_time DESC to return a CPU-intensive query. The SQL statement and the execution plan itself are al
This article will discuss and share with you some common classic queries of oracle SQL. You are welcome to add them. You can also share some classic queries. In this article, if you think there is any better solution to every problem, you are welcome to raise it in time. Communication and sharing can make progress together. Thank you!
Next four articles:
[Recommended] oracle SQL: html "> first article on cl
/sql/Tt$timestampsql_file= $HOME/sql/Tt.sqlEcho 'Start Time is:'$TIMESTAMPEcho 'SQL file is:'$SQL _fileEcho 'Out file is:'$PATH _filesqlplus-S $DB _user eof@ $SQL _file $PATH _fileQuiteofend_time=`Date+%y%m%d%h%m%S 'Echo$END _time3. You can create a Linux timed task, which i
EMP. Deptno=dept. DEPTNO--EG2:SELECT Ename,dname from Emp,deptWHERE EMP. Deptno=dept. DEPTNO and EMP. job= ' clerk ' --45 the name of the employee who is engaged in the sales job, assuming that the department number of the sales department is not known--EG1:SELECT EMP. Ename from EMP JOIN DEPTOn EMP. Deptno=dept. DEPTNO and Dname= ' SALES '--EG2:SELECT ename from Emp,deptWHERE EMP. Deptno=dept. DEPTNO and DEPT. Dname= ' SALES ' --46, list all employees who work in the same way as "SCOTT"--selec
. You can also add the keyword 'as' between the column name and the alias. the alias uses double quotation marks, so that the alias contains spaces or special characters and is case sensitive.
Connector:
Concatenates columns, columns, and characters. '|. It can be used to 'composite 'columns.
Example:
Select deptno | dname from dept;
DEPTNO | DNAME
------------------------------------------------------
10 ACCOUNTING
20 RESEARCH
30 SALES
40 OPERATIONS
String and date:
A string can be a characte
1. Obtain the first row of data in the table
select top 1 * from Dept
2. display a specific row in the first row
select DeptNO,DeptName,Phone,Manager,Deputy,Remark from dept where parentID='3' order by case when deptNO='3' then 0 else 1 end
3. SQL nested Query
select a,b,c from tableD where a=(select a from tableD)
select * from table1 where field1 in (select field1 from table2 where field2 in
The following is a query statement for viewing the field information of a table in SQL Server (taking the database pubs's jobs table as an example)Select sysobjects. Name as tablename,Syscolumns. Name as columnsname,Policypes. Name as datetype,Syscolumns. length as datelength,Sysproperties. value as remark -- column descriptionFrom sysobjects,Policypes,Syscolumns
Tags: tar create done Project class User A mat statusReference: https://bbs.csdn.net/topics/330032307There is a dictionary table in the database, which contains the ID field and the corresponding name fields.In another record table, there is a corresponding ID for the dictionary table above, and there are multiple fields that contain the ID field. It needs to be identified and used by name.SELECTa.ID as 'numbering',' Story' as 'type', A.title as 'title', B.name as 'Affiliated Projects', A.proje
nameSELECT * from emp order by ename;--18. Show employee name and date of employment, according to their service life, the oldest employee card at the frontSelect Ename, HireDate from emp order by HireDate;--19. Show the name/work and salary of all employees, sorted in descending order of work, sorted by salary if co-work is the sameSelect ename, Job, Sal from emp order by job Desc, Sal;--20. Displays the names of all employees/the year and month in which the company was joined, arranges the mo
reading the query plan, includingMsdnsome articles in the library. We are not going to expand or replace them here. In fact, we will provide many of these links at this level/Reference. Displays the graphical execution plan (http://msdn.microsoft.com/zh-cn/library/ms178071.aspx) is a good start. Other useful resources includeGrant Fritcheythe book,SQL ServerImplementation Plan (available free of charge in
A single table query is one that is relative to a multiple table query and refers to querying data from a datasheet.
4.2.1 Query all records
In the command edit area, perform the input "select * from Scott.emp" and click the Execute button to appear with all the records in the EMP datasheet as shown in Figure 4.3.
"See CD-ROM File": \ 4th Chapter \4.2\421.
plan after the query is executed. Obviously, the real plan is more accurate because it is physically running the query on the database. However, this approach may not be the best choice for a large and/or long-term system load query. In a typical case, I run this tool when I think a particular query is having a proble
st.text, Qp.query_plan
, qs.* from
sys.dm_exec_ Query_stats QS Cross
Apply Sys.dm_exec_sql_text (qs.plan_handle) St Cross
Apply Sys.dm_exec_query_plan ( Qs.plan_handle) QP
ORDER by Total_worker_time DESC
GO You can see here that I used a simple ORDER by Total_worker_time DESC to return a CPU-intensive query. The SQL statement and the execution plan itself are also fetched by invoking the sys.dm_ex
In most cases, upgrading your database to SQL Server 2008 can improve query performance. However, if you have mission-critical queries that have been carefully optimized for performance, it is a good idea to create a planning guide for each query before you upgrade to keep the query plans for those queries. If, after t
from t where num between 1 and 3
6. The following query will also result in a full table scan:
Select ID from t where name like '%abc% '
To improve efficiency, you can consider Full-text search.
7. The use of parameters in the WHERE clause also results in a full table scan. Because SQL resolves local variables only at run time, the optimizer cannot access the sched
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.