select * from tab1 where not exists (select 1 from tab2 where tab1.col=tab2.col)
是什么意思?
主要是select 1 from 看不懂?
是什么意思?
主要是select 1 from 看不懂?
解决方案 »
- sqlldr导入number类型数据时出错
- 如何让 用 group by 分组查询出来的数据以特定的顺序显示出来,而不是自动排列!!
- SQL 按照每个小时进行分组的sql语句,高手请!
- SQL数据库系统函数 datepart 转化 oracle数据中的使用????
- orcleXE中onlinelog文件自动丢失
- 有没有什么好的工具来分析sql语句的性能?
- 定时启动进程??
- 怎样提高在数百上千万条纪录中删除部分纪录的速度?
- 触发的简单问题
- 请教:谁知道哪有介绍oracle8i的语言设置的资料?
- oracle查看表与用户之间的关系
- windows系统被我ghost恢复了,但是在E盘的oracle目录。。。
--看这个条件tab1.col=tab2.col,如果存在这样的数据子查询就返回1.
--整个查询的意思就是在tab1中存在,在tab2中不存在的数据
因为你select 1 from tab2 where tab1.col=tab2.col这个查询不需要得到查询结果
用select 1 的效率比select columnname高 所有就用select 1select 1 from table;与select anycol(目的表集合中的任意一行) from table;与select * from table 从作用上来说是没有差别的,都是查看是否有记录,一般是作条件查询用的。select 1 from 中的1是一常量(可以为任意数值),查到的所有行的值都是它,但从效率上来说,1>anycol>*,因为不用查字典表。scott@YPCOST> select 1 from dept; 1
----------
1
1
1
1
1
1
1
1
select 1 from 就是说不关心具体的记录,只关心是否有结果。
如果有记录行(不管是一行还是多行,并且不管记录中字段内容如何),则条件返回为真,否则返回假。
select * from tab1 where not exists (select 1 from tab2 where tab1.col=tab2.col)select 1 1 不重要 只是匹配这个tab1.col=tab2.col 返回 true or false
随便你什么select 后面接什么都可以
跟 where tabl.col1 not in(select tab2.col1 from tab2) 意思一样
----------
1
执行计划
----------------------------------------------------------
Plan hash value: 3617692013------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| T1 | 1 | 3 (0)| 00:00:01 |
------------------------------------------------------------------Note
-----
- dynamic sampling used for this statement
统计信息
----------------------------------------------------------
0 recursive calls
0 db block gets
7 consistent gets
0 physical reads
0 redo size
412 bytes sent via SQL*Net to client
400 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processedSQL> select null from t1;N
-执行计划
----------------------------------------------------------
Plan hash value: 3617692013------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| T1 | 1 | 3 (0)| 00:00:01 |
------------------------------------------------------------------Note
-----
- dynamic sampling used for this statement
统计信息
----------------------------------------------------------
0 recursive calls
0 db block gets
7 consistent gets
0 physical reads
0 redo size
412 bytes sent via SQL*Net to client
400 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processedSQL>
1可能是第一条记录比较2表中的内容
我靠!这么多人抢分~