I am trying to create a table and columns in the table and then insert data in the columns. I’m using pgadmin4. This is my query:
INSERT INTO moon
(ID, NAME, Age, Salary)
VALUES
(2, 'saqib', 4, 400)
Error message:
ERROR: column "id" of relation "moon" does not exist
LINE 2: (ID, NAME, Age, Salary)
^
SQL state: 42703
Character: 19
The id column has been created in the table "moon" but still getting the error.
2
Answers
Note that the error messgage complains about the column
id
whereas you wroteID
in the query. You need to quote identifiers that are not all-lowercase like this:The error message you’re encountering indicates that PostgreSQL doesn’t recognize the column "ID" in your INSERT statement. The error message states that the column "id" (lowercase) doesn’t exist in the "moon" table, which suggests that there might be a case sensitivity issue.
In PostgreSQL, column names are case-sensitive by default. If you created the column with the name "ID" (uppercase), you need to reference it exactly the same way in your SQL queries.