Обсуждение: [BUGS] Creating a table by loading a sql file.
So I have this SQL code:
\c mydb;
CREATE TABLE USER(
ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
EMAIL TEXT NOT NULL,
PASSWORD TEXT NOT NULL,
);
INSERT INTO USER (name, email, password)
VALUES ('Tyler', 'tylerrobinson@whatver.com', 'tyler');
And I keep getting these errors:
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
psql:users.sql:10: ERROR: syntax error at or near "USER"
LINE 1: CREATE TABLE USER(
^
psql:users.sql:16: ERROR: syntax error at or near "USER"
LINE 1: INSERT INTO USER (name, email, password)
^ Hi, On Fri, 2017-10-27 at 04:55 +0000, rhodesm4 wrote: > psql:users.sql:10: ERROR: syntax error at or near "USER" > LINE 1: CREATE TABLE USER( USER is a reserved keyword in PostgreSQL: https://www.postgresql.org/docs/current/static/sql-keywords-appendix.html You need to change the table name. Regards, -- Devrim Gündüz EnterpriseDB: https://www.enterprisedb.com PostgreSQL Consultant, Red Hat Certified Engineer Twitter: @DevrimGunduz , @DevrimGunduzTR
On Fri, Oct 27, 2017 at 10:18 AM, Devrim Gündüz <devrim@gunduz.org> wrote:
Hi,
On Fri, 2017-10-27 at 04:55 +0000, rhodesm4 wrote:
> psql:users.sql:10: ERROR: syntax error at or near "USER"
> LINE 1: CREATE TABLE USER(
USER is a reserved keyword in PostgreSQL:
https://www.postgresql.org/docs/current/static/sql- keywords-appendix.html
You need to change the table name.
Or put double-quotes around the name: CREATE TABLE "USER"...
--
Alex