oracle 1=1 1=2 区别
来源:互联网 发布:阿里云杭州和北京对比 编辑:程序博客网 时间:2024/06/02 12:58
1=1 means true and 1=2 means false
where 1=2
create table t1 as select * from t
t1 will be same as t without data.
where 1=1
I have seen this clause many queries, i am not sure of the reason.
1.where 1=1:将返回一个true值,既条件为真。
还有其他的写法:where 0=0;where 'a'='a'等;
·常由程序(c++,java,c#等)生成,where条件中 1=1 之后的条件是通过 if 块动态变化的。
- String sql="select * from table_name where 1=1";
- if( conditon 1) {
- sql=sql+" and var2=value2";
- }
- if(conditon 2) {
- sql=sql+" and var3=value3";
- }
where 1=1 是为了避免where 关键字后面的第一个词直接就是“and”而导致语法错误。
·因为是一个永真条件,可以用于任何需要的地方。
- SQL> create table t as select * from dept where 1=1;
- SQL> select * from t;
- DEPTNO DNAME LOC
- ------ -------------- -------------
- 10 ACCOUNTING NEW YORK
- 20 RESEARCH DALLAS
- 30 SALES CHICAGO
- 40 OPERATIONS BOSTON
2.where 1=2:返回一个永假条件
其他写法:where 1>2; where 1=0等;
·建立表,与现有表结构相同,但是不需要向其填充任何数据
- SQL> create table t1 as select * from dept where 1=0;
- SQL> select * from t1;
- DEPTNO DNAME LOC
- ------ -------------- -------------
- SQL> desc t1;
- Name Type Nullable Default Comments
- ------ ------------ -------- ------- --------
- DEPTNO NUMBER(2) Y
- DNAME VARCHAR2(14) Y
- LOC VARCHAR2(13) Y
- oracle 1=1 1=2 区别
- Oracle数据库连接中Provider=OraOleDb.Oracle.1与Provider=MSDAORA什么区别
- 数据库使用学习笔记:Oracle数据库连接中Provider=OraOleDb.Oracle.1与Provider=MSDAORA什么区别
- ORACLE与SQLSERVER的区别-1
- 1oracle 自增长 2Oracle Sequence中Cache与NoCache的区别
- Oracle char(1)和varchar(1)的区别
- oracle中select 1和select *的区别
- oracle count(*),count(1)与count(rowid)区别
- Oracle 中count(1) 和count(*) 的区别
- Oracle 中count(1) 和count(*) 的区别
- Oracle 中count(1) 和count(*) 的区别
- Oracle 中count(1) 和count(*) 的区别
- Oracle 中count(1) 和count(*) 的区别
- Oracle 中count(1) 和count(*) 的区别
- Oracle 中count(1) 和count(*) 的区别
- oracle中:=与=:的区别
- oracle中:=与=:的区别
- 连接 oracle 连接串: OraOleDb.oracle.1 和 MSDAORA.1 区别
- oracle 建表空间和用户
- 可信软件方法学习
- JSP中如何通过JSP调用类(.java)中的方法
- 作为一个程序员需要学多少技能?
- java 日期校验 可以校验闰年
- oracle 1=1 1=2 区别
- 一步步优化JVM三:GC优化基础
- android adb shell
- I2S协议
- SYN-Flood遭遇战——Linux内核SYN-Cookie实现探究
- Extjs学习 XTemplate
- ExtJs大比拼JQuery:Dom文档操作
- 包含winsock2.h后出现type redefinition错误
- Team Queue STL