How to set the primary key self-increment when creating a table in a postgresql database using navicat?

clipboard.png

clipboard.png
No place was found.

Mar.16,2021

there is an auto_increment self-increment field in MySQL. PostgreSQL does not have a self-increment field, but there is a separate object: sequence. You can use sequences or other methods to implement such syntax. Or set the default value of a column to the value of sequence

set nextval ('products_product_no_seq') in the field default value.
create sequence see https://www.postgresql.org/do.

CREATE SEQUENCE products_product_no_seq START 101;
CREATE TABLE products (
    product_no integer DEFAULT nextval('products_product_no_seq'),
    ...
);

The

field type can be manually entered serial or serial8 . A sequence of table name _ field name _ seq is automatically created

Manual masturbation code can customize the seq name. Just the sauce.


clipboard.png

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e71549-34e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e71549-34e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?