Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting auto increment id in Postgres with Navicat

I'm rather new to Postgres and Navicat is the only fully functional GUI that I've come across. That said, I'm trying to implement a simple auto increment for an id. Navicat doesn't seem to support bigserial or serial, or have anything in place to specify a primary key w/ auto increment. Any thoughts?

like image 303
Nick Parsons Avatar asked Dec 01 '14 00:12

Nick Parsons


People also ask

Is there auto increment in PostgreSQL?

By simply setting our id column as SERIAL with PRIMARY KEY attached, Postgres will handle all the complicated behind-the-scenes work and automatically increment our id column with a unique, primary key value for every INSERT .

How do you get the last ID from a table if it's set to auto increment?

To get the next auto increment id in MySQL, we can use the function last_insert_id() from MySQL or auto_increment with SELECT. Creating a table, with “id” as auto-increment.

How do you set up Autoincrement?

In MySQL, the syntax to change the starting value for an AUTO_INCREMENT column using the ALTER TABLE statement is: ALTER TABLE table_name AUTO_INCREMENT = start_value; table_name. The name of the table whose AUTO_INCREMENT value you wish to change.


1 Answers

you should make a sequence default value

Navicat Menu -> Others -> Sequence -> (choose table and column) -> save "user_id_plus1"

and set default value for id column with

nextval('user_id_plus1'::regclass)
like image 50
Hamid Zandi Avatar answered Nov 03 '22 23:11

Hamid Zandi