10

Here is a Student table I coded in postgreSQL (an excerpt):

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...

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:

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?

1
  • Also in the INSERT INTO code, does it matter I wrap the data with a single quote or not? I see some code have single quotes and others don't. Commented Mar 22, 2012 at 0:04

2 Answers 2

11

you have created a table "Student" and you are trying to insert into a table called Student which are different

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you PresleyDias. It works now. Also thanks for the link, some good info in there.
3

Look for "quoted identifier" in "4.1.1. Identifiers and Key Words".

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".

1 Comment

Thank you. I'll look at it and get back to you if I have any problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.