Use the Shell to judge
#!/bin/sh
mypath= "/var/log/httpd/"
myfile= "/var/log/httpd/access.log"
if [!-X "$myPath"]; Then mkdir "$myPath" FI # Here's the-D parameter to determine if $mypath exists if [!-D "$myPath"]; Then mkdir "$myPath" FI # Here's the-f parameter to determine if $myfile exists if [!-F "$myFile"]; Then touch "$myFile" Fi # Other parameters-n,-n is to determine if a variable has a value
circumstances, we should reverse the insert Dave.
SQL> selectempno, ename from EMP where job in (select job from emp1 );
Empno ename
--------------------
7934 Miller
7900 James
7876 Adams
7369 Smith
7844 Turner
7654 Martin
7521 ward
7499 Allen
7782 Clark
7698 Blake
7566 Jones
Empno ename
--------------------
7902 Ford
7788 Scott
7839 king
14 rowsselected.
Change to exists for testing:
SQL> select empno, ename from emp a where not
I can see a good example on the Internet to explain the difference between in and exists.
This example shows how to query the title of a book published by any publisher in a city that starts with a letter B:Use pubs
Select titleFrom titles where exists(Select *From publishersWhere pub_id = titles. pub_idAnd city like 'B % ')Go
-- Or, using in:Use pubsGoSelect titleFrom titlesWhere pub_id in(Select pub_idFro
Analysis of exists and in, analysis of existsin
Exists and in do the same thing, so why do we need to get two more? It is actually a matter of efficiency.
For example, the following two examples
1. select * from t1 where exists (select 'x' from t2 where t1.a = t2.a)
PS: The 'X' here can be changed to any other regular bright, such as the numeric character etc.
2.
SQL determines whether a stored procedure exists
1 Determine if the database tutorial existsSQL codeif exists (SELECT * from sys.databases WHERE name = ' database name ')drop database [database name] if exists (SELECT * from sys.databases WHERE name = ' database name ')Drop DB [Database name]2 Determine if the table existsSQL codeif
User 1:
Review in exist Syntax:In general, in performs hash join on the External table and the internal table, while exist performs a nested loop on the External table and the internal table, that is, for exist, each row that needs to be traversed by the External table (all its content needs to be traversed) will be queried once for the internal table. Therefore, if the external table and the internal table are of the same size, in and exist are not very different in performance :)If one of the
Tags: als compare where effect cache table data Length statement elevationThe in statement applies to cases where a table is larger than table B SELECT * from a Where a_id in (select a_id from B); The EXISTS statement applies to cases where B is larger than table A. SELECT * from a WHERE EXISTS (select a_id from b where a.id = b.a_id); Reason: (Forward) SELECT * FROM Awhere ID in (select ID from B) The abov
Because to use in, later on the internet to find, found the following articles, we share a bit. Progress together. With in words, if there is an index, there is little difference in using join performance. Reprinted from Http://blog.chinaunix.net/u/4929/showart_1075412.htmlINDetermines whether the given value matches a subquery or a value in the list.EXISTSSpecifies a subquery that detects the presence of a row.Compare queries using EXISTS and inThis
, efficiency greatly improved.Conclusion: In () The case of B-table is smaller than the data of table ASelect A.* from a Awhere exists (select 1 from b b where a.id=b.id)The above query uses the EXISTS statement, exists () executes a.length times, and it does not cache the exists () result set because the contents of t
Specify a subquery to test whether the row exists.
Transact-SQL syntax conventions
Syntax
Exists subquery
Parameters
Subquery
Restricted select statements. The compute clause and the into keyword are not allowed. For more information, see "select (TRANSACT-SQL)" for information on subqueries.
Result type
The difference between in and exists and the efficiency of SQL executionMany forums have recently started to discuss the difference between in and exists and the efficiency of SQL execution,This paper deals with some differences between in and exists and the analysis of SQL execution efficiency.In SQL, in can be divided into three categories:1, Shape like select
Tags: and difficult to affect its causes cannot div save exampleObjectiveIn this section we analyze the left join and not EXISTS, short content, in-depth understanding, always to review the basics.Left JOIN ... Is null and NOT EXISTS analysisWe have previously analyzed that in query processing null value is based on the three-value logic, as long as there is null in the subquery when there is no data return
Oracle in and exists statements in and exists in use a hash connection between the external table and the internal table, while exists uses a loop for the External table. Each loop then queries the internal table. The argument that exists is more efficient than in is always inaccurate. Www.2cto.com if the two tables to
Brief introduction
Unrelated subqueries: Query criteria for subqueries are not dependent on parent queries called unrelated subqueries.
Correlated subqueries: A subquery's query condition relies on a property value of an outer parent query called a correlated subquery (correlated subquery), and a subquery with exists is a correlated subquery
exists represents the existence of quantifiers: s
ArticleDirectory
1. Example of replacing inner join with exists:
When using exists, if you can use it correctly, it may increase the query speed:
1. Replace inner join with exists
2. Replace in with exists
1. Example of replacing inner join with exists
Ext.: http://www.cnblogs.com/jhao/p/7243043.htmlIt is usually necessary to determine whether a file or directory exists before reading or writing the file, or some processing may cause the program to fail. So it's best to determine if the file exists before doing anything.Here are three ways to determine if a file or folder exists, respectively, and os模块 Try语句 pa
the host name or current machine "." Replace. But generally we install is similar to hostname\sqlexpress data source or host, so here needs to write "server=.\sqlexpress;" Or the "Data source=hostname\sqlexpress" form. 2 Database and Initial Catalog: Both effects seem to be similar. Used primarily to specify the database 3 Integrated Security: You can take a value of true, false, yes, no, or SSPI. SSPI represents the security Support Provider Interface, the effect is equivalent to true. When se
--whether the library existsif exists (select * from Master.. sysdatabases where Name=n ')print ' exists 'Elseprint ' NOT EXISTS '--Determine if the name of the table to be created exists, delete itif exists (SELECT * from dbo.sysobjects WHERE id = object_id (N ' [dbo].[ Tab
As long as Baidu isn't in and not exists, exclusively's not exists efficiency is better than not in, after all, not exists just to emphasize whether to return the result set, just a bool value, and not in is to return a result set, is composed of a large amount of data. So the first thing I did when I wrote is not in, and then my predecessors told me the efficien
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.