0

I am trying to import an SQL file with non english characters.

Below is the content of the SQL file.

CREATE TABLE IF NOT EXISTS `thebook` (
    `Book`  int(2),
    `Chapter` INTEGER,
    `Versecount` INTEGER,
    `verse` varchar(1024)
);
INSERT INTO "thebook" VALUES(0,1,1,'आरम्भमा परमेश्वरले आकाश र पृथ्वी सृष्टि गर्नु भयो।');
INSERT INTO "thebook" VALUES(0,1,2,'पृथ्वी शून्य थियो, पृथ्वीमा केही पनि थिएन। समुद्रलाई अँध्यारोले ढाकेको थियो अनि परमेश्वरको आत्मा पानीमाथि परिभ्रमण गरिरहन्थ्यो।');
INSERT INTO "thebook" VALUES(0,1,3,'तब परमेश्वरले भन्नुभयो, “उज्यालो होस्!” अनि उज्यालो चम्कन थाल्यो।');
INSERT INTO "thebook" VALUES(0,1,4,'परमेश्वरले उज्यालो देख्नु भयो अनि त्यसलाई असल मान्नु भयो। तब परमेश्वरले उज्यालो र अँध्यारोलाई छुट्याउनु भयो।');
INSERT INTO "thebook" VALUES(0,1,5,'परमेश्वरले उज्यालोलाई “दिन” र अँध्यारोलाई “रात” नाउँ दिनु भयो।साँझ पर्यो अनि बिहान भयो। यो पहिलो दिन थियो।');
INSERT INTO "thebook" VALUES(0,1,6,'तब परमेश्वरले भन्नुभयो, “पानीलाई दुइ भाग पार्न त्यहाँ बतास होस्!”');
INSERT INTO "thebook" VALUES(0,1,7,'यसर्थ परमेश्वरले त्यहाँ बतास सृष्टि गर्नुभयो अनि पानी छुट्टियो। केही पानी बतासमाथि रहयो अनि केही पानी बतास मुनि।');
INSERT INTO "thebook" VALUES(0,1,8,'परमेश्वरले त्यस बतासलाई “आकाश” नाउँ दिनु भयो। साँझ पर्यो अनि बिहान भयो। यो दोस्रो दिन थियो।तेस्रो दिन - सुख्खा भूमि र उद्भिद');
INSERT INTO "thebook" VALUES(0,1,9,'तब परमेश्वरले भन्नुभयो, “आकाश मुनिको पानी एकै ठाउँमा जम्मा होस्, र त्यहाँ सुख्खा भूमि देखियोस्।” अनि त्यस्तै भयो।');
INSERT INTO "thebook" VALUES(0,1,10,'त्यो सुख्खा भूमिलाई परमेश्वरले “पृथ्वी” नाउँ राख्नु भयो। अनि एकै ठाउँमा जम्मा भएको पानीलाई “समुद्र” नाउँ राख्नु भयो। परमेश्वरलाई यस्तो भएकोमा असल लाग्यो।');
INSERT INTO "thebook" VALUES(0,1,11,'तब परमेश्वरले भन्नुभयो, “पृथ्वीमा घाँस, अन्न उत्पन्न गर्ने उद्भिद तथा फल हुने बोटहरु उम्रियोस्। फल-रूखहरुले बीउ भएका फल फलाउने छन्। अनि प्रत्येक रूखले आफ्नै जातिका बीउ उब्जाउनेछ। यी उद्भिदहरू पृथवीमा उम्रिउन्।” अनि यस्तै भयो।');
INSERT INTO "thebook" VALUES(0,1,12,'पृथ्वीमा घाँस र उद्भिदहरू उम्रे अनि अन्नहरू फले। अनि पृथ्वीमा फलभित्र बीउहरु हुने फल फल्ने रुखहरु उम्रिए। प्रत्येक उद्भिदले आफ्नै प्रकारको बीउहरु सिर्जना गरे। अनि परमेश्वरले यिनलाई देखेर असल मान्नु भयो।');
INSERT INTO "thebook" VALUES(0,1,13,'साँझ पर्यो अनि बिहान भयो। यो तेस्रो दिन थियो।');
COMMIT;

To me, it looks like the syntax is correct but I am getting an error near the non english characters.

Error
SQL query:

INSERT INTO "thebook" VALUES(0,1,1,'आरम्भमा परमेश्वरले आकाश र पृथ्वी सृष्टि गर्नु भयो।')
MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"thebook" VALUES(0,1,1,'आरम्भमा परमेश्वरले आ' at line 1

Anyone knows how to deal with this problem for SQL containing non english contents?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Wayne
  • 763
  • 4
  • 21
  • 43
  • Possible duplicate of [When to use single quotes, double quotes, and backticks in MySQL](https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql) – Dharman Apr 29 '19 at 20:33

1 Answers1

2

Remove the double quotes around the identifier

INSERT INTO "thebook" VALUES(0,1,1,'...
            ^       ^

We can either leave the identifier (i.e. the table name) unescaped, or we can replace the double quotes with the MySQL standard backticks. As demonstrated in the CREATE TABLE statement.

INSERT INTO `thebook` VALUES(0,1,1,'...
            ^       ^

The default sql_mode causes MySQL to recognize tokens enclosed in double quotes as string literals. To get MySQL to recognize double quotes around identifiers, we'd need to include ANSI_QUOTES in sql_mode.


https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_ansi_quotes

ANSI_QUOTES

Treat " as an identifier quote character (like the ` quote character) and not as a string quote character. You can still use ` to quote identifiers with this mode enabled. With ANSI_QUOTES enabled, you cannot use double quotation marks to quote literal strings because they are interpreted as identifiers.

Community
  • 1
  • 1
spencer7593
  • 106,611
  • 15
  • 112
  • 140