postgresql 使用 INSERT INTO 时的错误信息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9814645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error message when using INSERT INTO
提问by Mr Teeth
Here is a Student table I coded in postgreSQL (an excerpt):
这是我在 postgreSQL 中编码的 Student 表(摘录):
CREATE TABLE "Student"
(
ucas_no integer NOT NULL,
student_name character(30) NOT NULL,
current_qualification character(30),
degree_of_interest character(30),
date_of_birth date NOT NULL,
street_address character(30) NOT NULL,
city character(30) NOT NULL,
post_code character(10) NOT NULL,
country character(20) NOT NULL,
phone_no character(15) NOT NULL,
gender character(6) NOT NULL,
user_name character(15) NOT NULL,
"password" character(30) NOT NULL,
CONSTRAINT pk_ucas_no PRIMARY KEY (ucas_no),
CONSTRAINT ten_digits_only CHECK (length(ucas_no::character(1)) >= 10 OR length(ucas_no::character(1)) <= 10)
)
Now i'm using the query tool feature of pgAdmin to insert data into the table. Here's the INSERT INTO code...
现在我正在使用 pgAdmin 的查询工具功能将数据插入表中。这是插入代码...
INSERT INTO Student
VALUES
('912463857', 'Jon Smith', 'A-Level', 'BSc(Hons) Computer Science', '10/06/1990', '50 Denchworth Road', 'LONDON', 'OBN 244', 'England', '02077334444', 'Male', 'jonsmi', '123456');
The problem I'm having is, i'm getting an error message saying the Student table does not exist, when it's clearly in my databse. Here's the error message:
我遇到的问题是,我收到一条错误消息,指出 Student 表不存在,但它显然在我的数据库中。这是错误消息:
ERROR: relation "student" does not exist
LINE 1: INSERT INTO Student (ucas_no, student_name, current_qualific...
^
********** Error **********
ERROR: relation "student" does not exist
SQL state: 42P01
Character: 13
Anyone have an idea what's wrong?
任何人都知道出了什么问题?
回答by PresleyDias
you have created a table "Student"
and you are trying to insert into a table called Student
which are different
您已经创建了一个表,"Student"
并且您正在尝试插入一个Student
不同的表
try this
试试这个
INSERT INTO "Student" VALUES('912463857', 'Jon Smith', 'A-Level', 'BSc(Hons) Computer Science', '10/06/1990', '50 Denchworth Road', 'LONDON', 'OBN 244', 'England', '02077334444', 'Male', 'jonsmi', '123456');
This will work
这将工作
please go through this about qoutes omitting-the-double-quote-to-do-query-on-postgresql
请仔细阅读有关 qoutes omitting -the-double-quote-to-do-query-on-postgresql 的内容
回答by Milen A. Radev
Look for "quoted identifier" in "4.1.1. Identifiers and Key Words".
在“4.1.1. Identifiers and Key Words”中查找“quoted identifier ”。
As for your second question (don't comment on your questions, edit them if related, create new if not) - read the whole "Chapter 4. SQL Syntax"of the manual, but the bare minimum is "4.1.2. Constants".
至于你的第二个问题(不要评论你的问题,如果相关就编辑它们,如果没有则创建新的) - 阅读手册的整个“第 4 章 SQL 语法”,但最低限度是“4.1.2.常量”。