pgsql 常用的建表语句

DROP TABLE IF EXISTS "public"."xxxxxx";
DROP SEQUENCE IF EXISTS "public"."xxxxxx_id_seq";
CREATE SEQUENCE "public"."xxxxxx_id_seq"
INCREMENT 1
MINVALUE  1
MAXVALUE 2147483647
START 1
CACHE 1;



CREATE TABLE "public"."xxxxxx" (
  "id" int4 NOT NULL DEFAULT nextval(‘xxxxxx_id_seq‘::regclass),
  "main_id" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "telephone" varchar(20),
  "send_message" int4,
  "times" int4,
  "type" int4,
  "create_time" timestamp(0),
  "update_time" timestamp(0)
)
;
COMMENT ON COLUMN "public"."xxxxxx"."telephone" IS ‘手机号码‘;
COMMENT ON COLUMN "public"."xxxxxx"."send_message" IS ‘是否需要发送短信‘;
COMMENT ON COLUMN "public"."xxxxxx"."times" IS ‘短信发送次数‘;
COMMENT ON COLUMN "public"."xxxxxx"."type" IS ‘发送短信类型‘;


CREATE INDEX "index_xxxxxx_main_id" ON "public"."xxxxxx" USING btree (
  "main_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);


GRANT Delete, Insert, Select, Truncate, Update ON TABLE "public"."xxxxxx" TO "user";
GRANT Update,Select ON TABLE "public"."xxxxxx_id_seq" TO "user";



pgsql 常用的建表语句

上一篇:mysql基础命令详解


下一篇:SQL按条件批量查询