Sign up ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.
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.

share|improve this question
1  
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. – Nick Barnes Apr 1 at 2:36
    
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 1 at 6:01

1 Answer 1

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?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.