X
X
xxxfdd2020-12-29 00:19:42
Python
xxxfdd, 2020-12-29 00:19:42

Why is there an error with AUTOINCREMENT?

I want to create a table where the id column will fill itself but gives an error. Here is the code:

curr.execute(
    f"CREATE TABLE orders (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, class text,)

psycopg2.errors.SyntaxError: ERROR: syntax error (example position: "AUTOINCREMENT")
LINE 1: CREATE TABLE orders (id INTEGER PRIMARY KEY AUTOINCREMENT NO...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2020-12-29
@xxxfdd

In postgresql you need to write

CREATE TABLE orders (
id serial primary key,
class text);

https://postgrespro.ru/docs/postgresql/9.6/datatyp...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question