Create a single-column increment row


CREATE SEQUENCE upms_log_id_seq START 10;
Copy the code

 

SQL > create database;

The key line

  • “ar_id” int4 DEFAULT nextval(‘upms_log_id_seq’::regclass) NOT NULL,
/* Navicat PGSQL Data Transfer Source Server: PostgreSql Source Server Version: 100700 Source Host: localhost:5432 Source Database : postgres Source Schema : public Target Server Type : PGSQL Target Server Version : 100700 File Encoding : 65001 Date: 2019-04-23 18:09:26 */ -- ---------------------------- -- Table structure for alarm_rules -- ---------------------------- DROP TABLE IF EXISTS "public"."alarm_rules"; CREATE TABLE "public"."alarm_rules" ( "ar_id" int4 DEFAULT nextval('upms_log_id_seq'::regclass) NOT NULL, "bc_id" int4 NOT NULL, "rule_name" varchar(100) COLLATE "default", "rule_type" varchar(100) COLLATE "default", "parameter_0" varchar(100) COLLATE "default", "parameter_1" varchar(100) COLLATE "default" ) WITH (OIDS=FALSE) ; COMMENT ON TABLE "public"."alarm_rules" IS 'ss '; COMMENT ON COLUMN "public"."alarm_rules"."ar_id" IS 'id'; COMMENT ON COLUMN "public"."alarm_rules"."bc_id" IS 'id'; COMMENT ON COLUMN "public"."alarm_rules"."rule_name" IS ' '; COMMENT ON COLUMN "public"."alarm_rules"."rule_type" IS 'type '; COMMENT ON COLUMN "public"."alarm_rules"."parameter_0" IS 'parameter '; COMMENT ON COLUMN "public"."alarm_rules"."parameter_1" IS 'parameter '; -- ---------------------------- -- Alter Sequences Owned By -- ---------------------------- -- ---------------------------- -- Primary Key structure for table alarm_rules -- ---------------------------- ALTER TABLE "public"."alarm_rules" ADD PRIMARY KEY ("ar_id");Copy the code