Home>

I am creating a todo list using springboot.
Among them, I thought about using Postgre as a database.
There is an error creating the table at the command prompt.

An error occurs when executing tododb =>\ i init_table.sql.
I want to eliminate this error.

tododb =>\ i init_table.sql
psql: init_table.sql: 10: ERROR: character with byte sequence 0xe7 0xac 0xa6 in encoding "UTF8" has no equivalent in encoding "WIN1252"
psql: init_table.sql: 13: ERROR: character with byte sequence 0xe7 0xac 0xa6 in encoding "UTF8" has no equivalent in encoding "WIN1252"
psql: init_table.sql: 16: ERROR: character with byte sequence 0xe7 0xac 0xa6 in encoding "UTF8" has no equivalent in encoding "WIN1252"
psql: init_table.sql: 19: ERROR: character with byte sequence 0xe7 0xac 0xa6 in encoding "UTF8" has no equivalent in encoding "WIN1252"
psql: init_table.sql: 22: ERROR: character with byte sequence 0xe7 0xac 0xa6 in encoding "UTF8" has no equivalent in encoding "WIN1252"
Corresponding source code

init_table.sql

CREATE TABLE to do
(
id SERIAL PRIMARY KEY,
title TEXT,
importance INTEGER,
urgency INTEGER,
deadline DATE,
done TEXT
);
INSERT INTO todo (title, importance, urgency, deadline, done)
VALUES ('todo-1', 0, 0, '2020-10-01','N');
INSERT INTO todo (title, importance, urgency, deadline, done)
VALUES ('todo-2', 0, 1, '2020-10-02','Y');
INSERT INTO todo (title, importance, urgency, deadline, done)
VALUES ('todo-3', 1, 0, '2020-10-03','N');
INSERT INTO todo (title, importance, urgency, deadline, done)
VALUES ('todo-4', 1, 1, '2020-10-04','Y');


init_database.sql

CREATE USER todouser WITH PASSWORD'pass';
CREATE DATABASE tododb OWNER todouser ENCODING'UTF8';
What I tried

The solution of logging in to postgresql and executing set client_encoding TO'UTF8';was on the WEB, so I tried it, but it caused garbled characters and the error was not resolved.

psql: init_table.sql: 10: ERROR: "PRIMARY KEY" a? _ A? Ya? _ A ?? a? Rè¿ `è_ºa? æ<æ-╪a," a لca ل¼
LINE 3: id SERIAL PRIMARY KEY,
^ ^
psql: init_table.sql: 13: ERROR: a لªa expensive ¬a ل¼ a, · a لa ➢ 3 "to do" a? _ å-~ å o "a?-a?
LINE 1: INSERT INTO todo (title, importance, urgency, deadline, done)
^ ^
psql: init_table.sql: 16: ERROR: a لªa expensive ¬a ل¼ a, · a لa00823 "to do" a? _ å-~ å o "a? -a? _A?>A,"
LINE 1: INSERT INTO todo (title, importance, urgency, deadline, done)
^ ^
psql: init_table.sql: 19: ERROR: a لªa expensive ¬a ل¼ a, · a لa00823 "todo" a? _å-~ å o "a? -a? _A?>A,"
LINE 1: INSERT INTO todo (title, importance, urgency, deadline, done)
^ ^
psql: init_table.sql: 22: ERROR: a لª a expensive ¬a ل¼ a, · a لaƒ 3 "to do" a? _ å-~ å o "a? -a?
LINE 1: INSERT INTO todo (title, importance, urgency, deadline, done)

environment

windows10
psql (PostgreSQL) 12.5

  • Answer # 1

    In reference
    The space between PRIMARY and KEY is meaningful, so don't cut it.