Why does Postgres say column does not exist? [duplicate]

此生再无相见时 提交于 2019-11-27 08:30:08

问题


So I have been working on the following sql script and I can't seem to figure out why it keeps telling me that the data I am inserting is in a column that doesn't exist. Can anyone more experianced with Postgre help me out?

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");

The error I am getting is:

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");

回答1:


Double quotes are used to specify the column name , So you can insert like:

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


来源:https://stackoverflow.com/questions/43671053/why-does-postgres-say-column-does-not-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!