create table in postgreSQL

前端 未结 4 1011
栀梦
栀梦 2021-01-30 08:07

I do not understand what is wrong with this query? Query tool does not want to create a table in PostgreSQL.

CREATE TABLE article (
article_id bigint(20) NOT NUL         


        
相关标签:
4条回答
  • 2021-01-30 08:40

    Replace bigint(20) not null auto_increment by bigserial not null and datetime by timestamp

    0 讨论(0)
  • First the bigint(20) not null auto_increment will not work, simply use bigserial primary key. Then datetime is timestamp in PostgreSQL. All in all:

    CREATE TABLE article (
        article_id bigserial primary key,
        article_name varchar(20) NOT NULL,
        article_desc text NOT NULL,
        date_added timestamp default NULL
    );
    
    0 讨论(0)
  • 2021-01-30 08:48

    Please try this:

    CREATE TABLE article (
      article_id bigint(20) NOT NULL serial,
      article_name varchar(20) NOT NULL,
      article_desc text NOT NULL,
      date_added datetime default NULL,
      PRIMARY KEY (article_id)
    );
    
    0 讨论(0)
  • 2021-01-30 08:58
    -- Table: "user"
    
    -- DROP TABLE "user";
    
    CREATE TABLE "user"
    (
      id bigserial NOT NULL,
      name text NOT NULL,
      email character varying(20) NOT NULL,
      password text NOT NULL,
      CONSTRAINT user_pkey PRIMARY KEY (id)
    )
    WITH (
      OIDS=FALSE
    );
    ALTER TABLE "user"
      OWNER TO postgres;
    
    0 讨论(0)
提交回复
热议问题