对不起,我无法复制这个。这是ij 的快速会议:
ij> create table "APP".REGISTRATION
> (
> id INTEGER generated by default as identity (start with 1, increment by 1) not null primary key,
> firstname VARCHAR(50),
> lastname VARCHAR(50),
> username VARCHAR(50),
> password VARCHAR(50),
> email VARCHAR(50)
> );
0 rows inserted/updated/deleted
ij> insert into "APP".registration (firstname, lastname, username, password, email) values ('susheel', 'singh', 'susheel61', 'password', 'test@gmail.com');
1 row inserted/updated/deleted
ij> select * from REGISTRATION where USERNAME='susheel61';
ID |FIRSTNAME |LASTNAME |USERNAME |PASSWORD |EMAIL
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 |susheel |singh |susheel61 |password |test@gmail.com
1 row selected
ij>
请注意,我必须更改您的 CREATE TABLE 语句才能创建表。您问题中的CREATE TABLE 语句无效;当我尝试运行它时出现“语法错误”。
编辑:现在您已经提供了用于创建表的实际 SQL 脚本,我可以解释其中的区别。
不同之处在于您在列名周围指定了双引号。这样做会使列名区分大小写。然后在查询表时必须使用双引号,除非列名都是大写的。如果您没有在名称周围指定双引号,则该名称将被视为全部大写。
以下是按照最初指定的方式查询表的方法:
ij> create table "APP".REGISTRATION
> (
> "id" INT not null primary key GENERATED ALWAYS AS IDENTITY(START WITH 1,INCREMENT BY 1),
> "firstname" VARCHAR(50),
> "lastname" VARCHAR(50),
> "username" VARCHAR(50),
> "password" VARCHAR(50),
> "email" VARCHAR(50)
> );
0 rows inserted/updated/deleted
ij> select * from "APP".registration where username = 'susheel61';
ERROR 42X04: Column 'USERNAME' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'USERNAME' is not a column in the target table.
ij> select * from "APP".registration where "username" = 'susheel61';
id |firstname |lastname |username |password |email
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0 rows selected
ij>
(这次我没有费心插入任何数据,但希望您仍能明白这一点:查询完成且没有错误。)
请注意,这次的列标题是小写的,而上面输出的第一部分中的列标题是大写的。