ERROR: column "username" of relation "public.ae_User" does not exist - Postgresql
ERROR: column "username" of relation "public.ae_User" does not exist - Postgresql
我正在学习 postgresql 并在 elephantsql 中制作这个 table:
CREATE TABLE "public.ae_User" (
"Id" serial NOT NULL,
"Name" character varying(30) NOT NULL,
"Username" character varying(16) NOT NULL UNIQUE DEFAULT 'Guest',
"Email" character varying(30) NOT NULL,
"Password" character varying(120) NOT NULL,
"Salt" character varying(40) NOT NULL,
"User_type" int NOT NULL DEFAULT '0',
"Deleted" BOOLEAN NOT NULL DEFAULT 'false',
CONSTRAINT "ae_User_pk" PRIMARY KEY ("Id")
) WITH (
OIDS=FALSE
);
但是当我尝试插入时:
INSERT INTO "public"."public.ae_User" (Name, Username, Email, Password, Salt, User_type, Deleted)
VALUES ("Miguel", "adminMiguel", "miguel@gmail.com", "admin", "bla", 3, false)
它returns:
ERROR: column "username" of relation "public.ae_User" does not exist
LINE 1: INSERT INTO "public"."public.ae_User" (Username, Email, Pass...
你的错误在 INSERT INTO "public"."public.ae_User"
被替换为 INSERT INTO "public"."ae_User"
您应该在列名中使用双引号,因为 Postgres 将列折叠为小写。
如果该列包含大写字母(and/or 其他语法违规)您必须使用 双引号
另一方面,对于文本或 varchar 数据,您必须使用 单引号
INSERT INTO "public"."public.ae_User" ("Name", "Username", "Email", "Password", "Salt", "User_type", "Deleted")
VALUES ('Miguel', 'adminMiguel', 'miguel@gmail.com', 'admin', 'bla', 3, false)
P.S:
在我看来,最好像下面这样更改结构:
CREATE TABLE public."ae_User" (
"Id" serial NOT NULL,
"Name" character varying(30) NOT NULL,
"Username" character varying(16) NOT NULL UNIQUE DEFAULT 'Guest',
"Email" character varying(30) NOT NULL,
"Password" character varying(120) NOT NULL,
"Salt" character varying(40) NOT NULL,
"User_type" int NOT NULL DEFAULT '0',
"Deleted" BOOLEAN NOT NULL DEFAULT 'false',
CONSTRAINT "ae_User_pk" PRIMARY KEY ("Id")
) WITH (
OIDS=FALSE
);
INSERT INTO public."ae_User" ("Name", "Username", "Email", "Password", "Salt", "User_type", "Deleted")
VALUES ('Miguel', 'adminMiguel', 'miguel@gmail.com', 'admin', 'bla', 3, false)
我正在学习 postgresql 并在 elephantsql 中制作这个 table:
CREATE TABLE "public.ae_User" (
"Id" serial NOT NULL,
"Name" character varying(30) NOT NULL,
"Username" character varying(16) NOT NULL UNIQUE DEFAULT 'Guest',
"Email" character varying(30) NOT NULL,
"Password" character varying(120) NOT NULL,
"Salt" character varying(40) NOT NULL,
"User_type" int NOT NULL DEFAULT '0',
"Deleted" BOOLEAN NOT NULL DEFAULT 'false',
CONSTRAINT "ae_User_pk" PRIMARY KEY ("Id")
) WITH (
OIDS=FALSE
);
但是当我尝试插入时:
INSERT INTO "public"."public.ae_User" (Name, Username, Email, Password, Salt, User_type, Deleted)
VALUES ("Miguel", "adminMiguel", "miguel@gmail.com", "admin", "bla", 3, false)
它returns:
ERROR: column "username" of relation "public.ae_User" does not exist
LINE 1: INSERT INTO "public"."public.ae_User" (Username, Email, Pass...
你的错误在 INSERT INTO "public"."public.ae_User"
被替换为 INSERT INTO "public"."ae_User"
您应该在列名中使用双引号,因为 Postgres 将列折叠为小写。
如果该列包含大写字母(and/or 其他语法违规)您必须使用 双引号
另一方面,对于文本或 varchar 数据,您必须使用 单引号
INSERT INTO "public"."public.ae_User" ("Name", "Username", "Email", "Password", "Salt", "User_type", "Deleted")
VALUES ('Miguel', 'adminMiguel', 'miguel@gmail.com', 'admin', 'bla', 3, false)
P.S:
在我看来,最好像下面这样更改结构:
CREATE TABLE public."ae_User" (
"Id" serial NOT NULL,
"Name" character varying(30) NOT NULL,
"Username" character varying(16) NOT NULL UNIQUE DEFAULT 'Guest',
"Email" character varying(30) NOT NULL,
"Password" character varying(120) NOT NULL,
"Salt" character varying(40) NOT NULL,
"User_type" int NOT NULL DEFAULT '0',
"Deleted" BOOLEAN NOT NULL DEFAULT 'false',
CONSTRAINT "ae_User_pk" PRIMARY KEY ("Id")
) WITH (
OIDS=FALSE
);
INSERT INTO public."ae_User" ("Name", "Username", "Email", "Password", "Salt", "User_type", "Deleted")
VALUES ('Miguel', 'adminMiguel', 'miguel@gmail.com', 'admin', 'bla', 3, false)