【问题标题】:Syntax error at or near AS integer when creating a sequence创建序列时在 AS 整数处或附近出现语法错误
【发布时间】:2019-01-12 21:22:12
【问题描述】:

当我尝试使用 psql 执行时,我在下面的代码中收到“错误等于或接近 AS 整数”。

CREATE SEQUENCE public.auth_group_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

以上sql语句来自本地机器postgres 11版本的备份文件,在EC2 postgres 9.3版本中执行。我是 postgres 的新手,不知道因为 sql 仅由 postgres 生成,所以它应该与 psql 一起使用。提前致谢。

【问题讨论】:

    标签: postgresql postgresql-9.3 postgresql-11


    【解决方案1】:

    Postgres 9.3(即no longer supported)不支持AS data_type 选项。这是在版本 10 中引入的。

    您可以尝试使用 9.3 安装中的 pg_dump 进行转储,但我不确定这是否有效。

    【讨论】:

      【解决方案2】:

      一些对我有用的解决方法。在这种情况下,您只需从转储文件中删除 AS integer

      sed 's/    AS integer$//g' your_dump_file.out > tmp.out
      mv tmp.out your_dump_file.out
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-12-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多