为什么我的PostgreSQL SQL上出现语法错误?

时间:2015-04-01 01:19:46

标签: postgresql phppgadmin

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

我正在尝试在PostgreSQL数据库中使用提供的语句,但是当我尝试执行它时,我收到语法错误:

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

据我所知,我的SQL很好。我不确定这里出了什么问题。

1 个答案:

答案 0 :(得分:-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'
);

移动约束语法有帮助吗?