Auto Generate?
In PostgreSQL, Auto Generate usually means automatically generating values for a column, such as an ID.
You can use SERIAL or GENERATED AS IDENTITY.
Example: Using SERIAL
CREATE TABLE student ( id SERIAL PRIMARY KEY , name VARCHAR ( 50 ) , age INT ) ;
Enter fullscreen mode
Exit fullscreen mode
Two ways to auto-generate IDs
SERIAL --> id SERIAL
Identity --> id INT GENERATED ALWAYS AS IDENTITY
Primary Keys
A primary key constraint indicates that a column, or group of columns, can be used as a unique identifier for rows in the table. This requires that the values be both unique and not null.…