Help Center/
GaussDB/
Developer Guide(Centralized_8.x)/
FAQ/
How do I create an auto-increment column?
Updated on 2024-06-03 GMT+08:00
How do I create an auto-increment column?
Answer: GaussDB supports the creation of auto-increment columns. You can specify the SERIAL data type when creating a table.
Example:
gaussdb=#CREATE TABLE table_name(id serial, name varchar(20));
You can also use the following method:
-- Create a sequence. gaussdb=#CREATE SEQUENCE tbl_person_id_seq; -- Create the tbl_persion table. The value of the id column is automatically increased based on the sequence specified by tbl_person_id_seq. gaussdb=#CREATE TABLE tbl_persion( id int NOT NULL DEFAULT nextval('tbl_person_id_seq'::regclass), name varchar(20));
Parent topic: FAQ
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot