Getting sintax error while import dump into postgresql in Linux - sql

I installed Postgresql on the Redhat Linux server and try to import the dump into the database At that time I'll get a syntax error.
sudo -u postgres -i psql db_test < data.sql
psql -h localhost -U postgres -W -d postgres < data.sql
Iam used these two commands to import data. At that time I'll get syntax error like this.
ERROR: syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `comment_details`;
^
ERROR: syntax error at or near "`"
LINE 1: CREATE TABLE `comment_details` (
^
ERROR: syntax error at or near "`"
LINE 1: LOCK TABLES `comment_details` WRITE;
^
ERROR: syntax error at or near "`"
LINE 1: INSERT INTO `comment_details` VALUES (3,1140,'ANAKAPALLI MAN...
^
ERROR: syntax error at or near "UNLOCK"
LINE 1: UNLOCK TABLES;
^
ERROR: syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `directory_org_details`;
^
ERROR: syntax error at or near "`"
LINE 1: CREATE TABLE `directory_org_details` (
^
ERROR: syntax error at or near "`"
LINE 1: LOCK TABLES `directory_org_details` WRITE;
^
invalid command \'s
invalid command \'s
invalid command \'s
ERROR: syntax error at or near "`"
LINE 1: INSERT INTO `directory_org_details` VALUES (1,'Daniel\'s Cri...
Please Help regarding This issue. Thanks in Advance.

Related

How to fix syntax error at or near "psql" in psql ubuntu

I am entirely new to psql and not particularly familiar with some terms. I am following instructions on an ETL process for mimic-in the link here: https://github.com/chichukw/mimic-omop/blob/master/README-run-etl.md. When I run this code, it shows no output but this error:
syntax error at or near "psql"
I have tried adding semicolon, removing the psql part and removing the quotes and dollar sign but I still get this syntax error on the first character regardless.
psql "$MIMIC" postgres_create_mimic_id.sql;
I expect concept ids to be created after running this code on the server using the jupyter terminal.
The only way I can think of how you could get that output/error is if you did this:
[root#foo /]# psql
psql (11.5)
Type "help" for help.
postgres=# psql "$MIMIC" postgres_create_mimic_id.sql;
ERROR: syntax error at or near "psql"
LINE 1: psql "$MIMIC" postgres_create_mimic_id.sql;
^
postgres=#
Instead, I think you should be doing this:
[root#foo /]# export MIMIC='host=localhost dbname=postgres user=postgres options=--search_path=mimiciii'
[root#foo /]# psql "$MIMIC" -f postgres_create_mimic_id.sql;
Disclosure: I am an EnterpriseDB (EDB) employee

Can not export hive dat to local "cannot recognize input near '<EOF>' '<EOF>' '<EOF>'"

My query is insert overwrite local directory '/home/localfile'
And what is get is:
Error: Error while compiling statement: FAILED: ParseException line 1:48 cannot recognize input near '<EOF>' '<EOF>' '<EOF>' in statement (state=42000,code=40000)

Error loading yelp dataset to postgreSQL

I'm trying to import the Yelp data from their sql file into a postgreSQL 10 database on Windoes by running the code:
psql -U postgres yelp_db < yelp_sql
and getting the errors below. As you can see it is probably due to the ` character. Is there any way to easy fix that? The file is 7.3GB so I'd like to avoid having to read it line by line to change the ` character to '.
ERROR: syntax error at or near "PaxHeader"
LINE 1: PaxHeader/yelp_db.sql17 uid=998889796
^
ERROR: syntax error at or near "`"
LINE 1: CREATE DATABASE /*!32312 IF NOT EXISTS*/ `yelp_db` /*!40100 ...
^
ERROR: syntax error at or near "USE"
LINE 1: USE `yelp_db`;
^
ERROR: syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `attribute`;
^
ERROR: syntax error at or near "`"
LINE 1: CREATE TABLE `attribute` (

Postgresql import dump with pgadmin3

i have been trying to import a Postgresql dump with my pgadmin3 interface but im running into problems. These dump was generated with pg_dump dbname > dump_file.sql
ERROR: syntax error at or near "\"
LINE 1903: \.
^
********** Error **********
ERROR: syntax error at or near "\"
SQL state: 42601
Character: 45693
the code:
--
-- Data for Name: auth_group; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY auth_group (id, name) FROM stdin;
\.
thanks
PgAdmin-III's SQL window unfortunately does not understand psql backslash commands, COPY ... FROM STDIN, etc.
You must restore with psql.
psql -f dump_file.sql

Importing .sql file into SQLite

I'm trying to import a large .sql file into an SQLite .db file, but I'm getting the following errors:
sqlite> .read ./smsCorpus_en_2012.04.30.sql
Error: near line 23: near "COMMENT": syntax error
Error: near line 50: near "LOCK": syntax error
Error: near line 52: near "some1": syntax error
Error: near line 58: near "s": syntax error
Error: near line 60: near "s": syntax error
Error: near line 66: near "UNLOCK": syntax error
The file is located at http://wing.comp.nus.edu.sg:8080/SMSCorpus/data/corpus/smsCorpus_en_sql_2012.04.30.zip (direct file link) linked on this page http://wing.comp.nus.edu.sg:8080/SMSCorpus/history.jsp
EDIT: just a warning, the file is quite large...not sure if this is the issue?
That file is a MySQL dump.
To make SQLite understand it, you have to:
delete COMMENTs on the table fields;
remove AUTO_INCREMENT from id (INTEGER PRIMARY KEY fields are autoincrementing in SQLite anyway);
remove ENGINE and DEFAULT CHARSET;
remove LOCK/UNLOCK commands;
make the INSERT commands have fewer records;
replace \' quoting with ''.
That is a MySQL Dump and not SQLite.
There are slight variations on the syntax.