没看出有什么奇怪的??~~
SQL> conn scott/tiger
已连接。
SQL> create table users (user_name char(10),user_id int);表已创建。SQL> insert into users values ('ADMIN',1);已创建 1 行。SQL> commit;提交完成。SQL> select * from users;USER_NAME USER_ID
---------- ----------
ADMIN 1SQL> select * from users where user_name='ADMIN';USER_NAME USER_ID
---------- ----------
ADMIN 1SQL> select USER_ID from users where user_name='ADMIN'; USER_ID
----------
1SQL>
SQL> conn scott/tiger
已连接。
SQL> create table users (user_name char(10),user_id int);表已创建。SQL> insert into users values ('ADMIN',1);已创建 1 行。SQL> commit;提交完成。SQL> select * from users;USER_NAME USER_ID
---------- ----------
ADMIN 1SQL> select * from users where user_name='ADMIN';USER_NAME USER_ID
---------- ----------
ADMIN 1SQL> select USER_ID from users where user_name='ADMIN'; USER_ID
----------
1SQL>
select * from users where user_id=1; user_id
----------
user_name
--------------------------------------------------------------------------------
user_pwd
--------------------------------------------------------------------------------
user_purview user_msg
------------ ----------
1
ADMIN
ypxJGsZrLGJQCILpPzcZqA==
1 0
select * from users where user_id=1
*
ERROR 位于第 1 行:
ORA-00904: 无效列名
"user_id" int not null,
"user_name" NVARCHAR2(50),
"user_pwd" NVARCHAR2(50),
"user_purview" int,
"user_msg" INT
);comment on table USERS is
'用户表';表已创建。
注释已创建。insert into users values(0,'admin','admin',0,0);已创建 1 行。select * from users user_id
----------
user_name
--------------------------------------------------------------------------------
user_pwd
--------------------------------------------------------------------------------
user_purview user_msg
------------ ----------
0
ADMIN
ypxJGsZrLGJQCILpPzcZqA==
0 0select * from users where user_name=0
ERROR 位于第 1 行:
ORA-00904: 无效列名
select column_name from user_tab_columns where table_name='USERS'
查出你该表的字段名(注意大小敏感的)再写你的查询,如
select * from users where "col1"=... and "col2"=...(字段名在引号内大小敏感)
------------------------------
user_id
user_name
user_pwd
user_purview
user_msgselect * from USERS where "user_id"=1;未选定行select * from USERS where user_id=1;
*
ERROR 位于第 1 行:
ORA-00904: 无效列名偶要哭啦!!大家救救偶啊……
感谢ORARichard哥哥!!
select * from USERS where "user_id"=0;这个可以查到!!
但是为什么偏偏要加双引号哩??
SQl不是不分大小写的吗??请赐教...
SQL> select * from c where "c3"=3;
select * from c where "c3"=3
*
ERROR 位于第 1 行:
ORA-00904: "c3": 无效的标识符
怎么回事???
你可能应该写select * from c where "C3"=3;
你创建表时
create table USERS (
"user_id" int not null,
"user_name" NVARCHAR2(50),
"user_pwd" NVARCHAR2(50),
"user_purview" int,
"user_msg" INT
);
表的字段是小写的~
而select **** where 字段
此时你无论大小写都默认转换成大写,从而查不到小写的字段1、要么建表不要加引号;
2、要么select 字段加引号~