Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

postgreSQL syntax error at or near "INSERT"

Tags:

sql

postgresql

Here is my code:

SET SEARCH_PATH TO work

/* Task 1 */

INSERT INTO Category (CategoryID, Name, CategoryType)    

VALUES(1,'English','fiction');

and here is the error:

ERROR:  syntax error at or near "INSERT"
LINE 4: INSERT INTO Category (CategoryID,Name,CategoryType)
          ^
********** Error **********

ERROR: syntax error at or near "INSERT"
SQL state: 42601
Character: 45
like image 275
aster Avatar asked Apr 26 '16 21:04

aster


People also ask

What Is syntax error at or near?

This SQL error generally means that somewhere in the query, there is invalid syntax. Some common examples: Using a database-specific SQL for the wrong database (eg BigQuery supports DATE_ADD, but Redshift supports DATEADD) Typo in the SQL (missing comma, misspelled word, etc)

Does not exist SQL state 42703?

Another common error code with PostgreSQL database is 42703 as well as the error message “column does not exist”. This error indicates either that the requested column does not it exist, or that the query is not correct.

How do I connect to a Postgres database?

In order to connect to a database you need to know the name of your target database, the host name and port number of the server, and what user name you want to connect as. psql can be told about those parameters via command line options, namely -d, -h, -p, and -U respectively.


1 Answers

You need a semi-colon at the end of the SET statement:

SET SEARCH_PATH TO work;
like image 80
Ray O'Donnell Avatar answered Sep 19 '22 12:09

Ray O'Donnell