This question already has answers here:
delete “column does not exist”

(1 个回答)



Column 'mary' does not exist

(2 个回答)



postgres - where in (list) - column does not exist

(2 个回答)


1年前关闭。




所以我一直在研究下面的 sql 脚本,我似乎无法弄清楚为什么它一直告诉我我插入的数据在一个不存在的列中。任何对 Postgre 有更多经验的人都可以帮助我吗?
DROP SCHEMA pomodoro CASCADE;
CREATE SCHEMA pomodoro;
CREATE TABLE pomodoro.users
(
    uid smallint NOT NULL,
    username text NOT NULL,
    password text NOT NULL,
    weekly_goals bytea,
    CONSTRAINT users_pkey PRIMARY KEY (uid)
) WITH (OIDS=FALSE);

INSERT INTO pomodoro.users (uid, username,password)
VALUES (1,"dan","pass");

我得到的错误是:
INSERT INTO pomodoro.users (uid, username,password)
VALUES (1,"dan","pass");
psql:database-backup/start-script.sql:27: ERROR:  column "dan" does not exist
LINE 2: VALUES (1,"dan","pass");

最佳答案

双引号用于指定列名,因此您可以像这样插入:

INSERT INTO pomodoro.users (uid, username,password) VALUES (1,'dan','pass');

关于sql - 为什么 Postgres 说列不存在?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43671053/

10-10 22:43