如select * from message where name=‘Tom';
select * from message where name="Tom"
结果都一样吧,看到书里有时用单引号,有时用双引号
我们的教材好像很多时候都是单引号
select * from message where name="Tom"
结果都一样吧,看到书里有时用单引号,有时用双引号
我们的教材好像很多时候都是单引号
调试欢乐多
这上面区别我知道,但是select * from table_name where id=“1”,是什么区别,那位能不能解释一下,谢谢
default关键字后面只能使用单引号。
你这样是没有区别
elect ''Tom'' from message
select ‘Tom' from message
如果是这样就有区别了,第一个查表的字段,第二个就是字符
select ‘Tom' from message
如果是这样就有区别了,第一个查表的字段结果查的是什么,第二个查的是字符串我知道
SQL> create table aa(i varchar2(10));Table createdSQL> insert into aa ("aaa");insert into aa ("aaa")ORA-00926: 缺失 VALUES 关键字SQL> insert into aa values("aaa");insert into aa values("aaa")ORA-00984: 列在此处不允许SQL> insert into aa values('aaa');1 row insertedSQL> commit;Commit completeSQL> select * from aa where i = "aaa";select * from aa where i = "aaa"ORA-00904: "aaa": 标识符无效SQL> select * from aa where i = 'aaa'
2 ;I
----------
aaaSQL>被你差点忽悠了,加双引号的字符都是非法的操作
create table aa("i" varchar2(20));
SQL> select "i" from aa;i
----------SQL
--SELECT * FROM EMP WHERE ename="smith";
--create table aa("i" varchar2(20));
select "i" from aa;SELECT * FROM EMP WHERE ename="smith"
*
第 1 行出现错误:
ORA-00904: "smith": 标识符无效表已创建。
未选定行
提示下面为选定行
create table aa("i" varchar2(20));
SQL> select "i" from aa;i
----------
现在有一点懂了,只是9楼
create table aa("i" varchar2(20));
SQL> select "i" from aa;个他可以查出是i
我却提示未选定行,编译器不同??
[TEST1@orcl#27-12月-10] SQL>create table y_two(id number,"id" number,"Id" number);表已创建。[TEST1@orcl#27-12月-10] SQL>create table y_three(id number,Id number,ID number);
create table y_three(id number,Id number,ID number)
*
第 1 行出现错误:
ORA-00957: 重复的列名数据库一个表的列名是不能重复,由上可知,"Id"与id 并不相同
[TEST1@orcl#27-12月-10] SQL>insert into y_two values(1,2,3);已创建 1 行。[TEST1@orcl#27-12月-10] SQL>commit;提交完成。[TEST1@orcl#27-12月-10] SQL>select * from y_two; ID id Id
---------- ---------- ----------
1 2 3注意看上面的3个列名。与建表的列名比较。
如果建表时候列名没有用双引号,在数据库中显示是大写。如果有双引号,则区分大小写。
[TEST1@orcl#27-12月-10] SQL>select "Id" from y_two; Id
----------
3[TEST1@orcl#27-12月-10] SQL>select Id from y_two; ID
----------
1用双引号括起来的列名 查询时也必须括起来
双引号表示标识符,比如别名,列名,表名,存储过程名等。
一般情况下标识符oracle会自动转为大写再跟数据字典做比较。如果加了双引号则不再做大写转换,直接按双引号内的内容进行比较。所以一般不加双引号。
比如你建表时指定表名为"T_able",那么以后再引用这张表只能写"T_able",而不能是T_able
create table aa("i" varchar2(20));
SQL> select "i" from aa;
对于字符 日期都得加双引号处理 除非插入的时候含特殊字符 也一样
select * from message where name='Tom';
select * from message where name='"Tom"'
对于字符 日期都得加单引号处理 除非插入的时候含特殊字符 也一样
select * from message where name='Tom';
select * from message where name='"Tom"'