pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Creating a table by loading a sql file.
3+ messages / 3 participants
[nested] [flat]

* Creating a table by loading a sql file.
@ 2017-10-27 04:55  rhodesm4 <rhodesm4@msu.edu>
  0 siblings, 1 reply; 3+ messages in thread

From: rhodesm4 @ 2017-10-27 04:55 UTC (permalink / raw)
  To: pgsql-bugs

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)
                                     ^

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Creating a table by loading a sql file.
@ 2017-10-27 08:18  Devrim Gündüz <devrim@gunduz.org>
  parent: rhodesm4 <rhodesm4@msu.edu>
  0 siblings, 1 reply; 3+ messages in thread

From: Devrim Gündüz @ 2017-10-27 08:18 UTC (permalink / raw)
  To: rhodesm4 <rhodesm4@msu.edu>; pgsql-bugs


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

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Creating a table by loading a sql file.
@ 2017-11-02 09:57  Oleksandr Shulgin <oleksandr.shulgin@zalando.de>
  parent: Devrim Gündüz <devrim@gunduz.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Oleksandr Shulgin @ 2017-11-02 09:57 UTC (permalink / raw)
  To: Devrim Gündüz <devrim@gunduz.org>; +Cc: rhodesm4 <rhodesm4@msu.edu>; pgsql-bugs

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

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2017-11-02 09:57 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-10-27 04:55 Creating a table by loading a sql file. rhodesm4 <rhodesm4@msu.edu>
2017-10-27 08:18 ` Devrim Gündüz <devrim@gunduz.org>
2017-11-02 09:57   ` Oleksandr Shulgin <oleksandr.shulgin@zalando.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox