1
CREATE TABLE members (
    memberID SERIAL,
    username VARCHAR(255) NOT NULL,
    password VARCHAR(60) NOT NULL,
    email VARCHAR(255) NOT NULL,
    active VARCHAR(255) NOT NULL,
    resetToken VARCHAR(255) DEFAULT NULL,
    resetComplete VARCHAR(3) DEFAULT 'No',
    CONSTRAINT members_pk PRIMARY KEY (memberID)
);

I am trying to use the provided statement in my PostgreSQL db, but when I attempt to execute it I am getting a syntax error:

ERROR:  syntax error at or near "CREATE"
LINE 1: SELECT COUNT(*) AS total FROM (CREATE TABLE members (

As far as I know, my SQL is fine. I am not sure what is going wrong here.

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
Jared
  • 81
  • 1
  • 2
  • 6
  • 9
    It's not Postgres' fault. It's a bug in the tool you're using to run the query, which I'm guessing is phpPgAdmin. If so, you can prevent it by [disabling pagination](http://stackoverflow.com/questions/18368831/postgres-sql-insert-query-syntax-error). – Nick Barnes Apr 01 '15 at 02:36
  • 1
    Nick, you were correct in your assumption and your suggestion. Thanks! This is my first go-round with PostgreSQL and it's been a frustrating experience. Since you posted as a comment, however, I cannot accept your response as the answer. – Jared Apr 01 '15 at 06:01

1 Answers1

-3
CREATE TABLE members (
    memberID SERIAL CONSTRAINT members_pk PRIMARY KEY,
    username VARCHAR(255) NOT NULL,
    password VARCHAR(60) NOT NULL,
    email VARCHAR(255) NOT NULL,
    active VARCHAR(255) NOT NULL,
    resetToken VARCHAR(255) DEFAULT NULL,
    resetComplete VARCHAR(3) DEFAULT 'No'
);

Does moving constraint syntax help?

bf2020
  • 742
  • 4
  • 7