manny8086
manny8086

Reputation: 509

Syntax error at or near AS integer when creating a sequence

I am getting "error at or near AS integer" in below code when I am trying to execute with psql.

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

The above sql statement is from the backup file of local machine postgres version 11 and executing in EC2 postgres version 9.3. I am new to postgres and getting no idea as the sql is generated by postgres only so it should work with psql. Thanks in advance.

Upvotes: 6

Views: 4809

Answers (2)

Stanislav Savchuk
Stanislav Savchuk

Reputation: 41

Some workaround that works for me. In this case, you simply have to remove AS integer from the dump file.

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

Upvotes: 4

user330315
user330315

Reputation:

Postgres 9.3 (which is no longer supported) did not support the AS data_type option. This was introduced in version 10.

You could try using pg_dump from your 9.3 installation to do the dump, but I am not sure if that works.

Upvotes: 13

Related Questions