【PostgreSQL】------ pg sql先判断是否存在表在创建表结构--实例代码

// if not exists 不存在
CREATE TABLE if not exists "public"."DCS_YZYHK_CARD" (
  "ID" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "ORG_ID" varchar(50) COLLATE "pg_catalog"."default",
  "ORG_NAME" varchar(100) COLLATE "pg_catalog"."default",
  "ZW_NAME" varchar(100) COLLATE "pg_catalog"."default",
  "ZW_ID" varchar(50) COLLATE "pg_catalog"."default",
  "DPT_NAME" varchar(100) COLLATE "pg_catalog"."default",
  "DPT_ID" varchar(50) COLLATE "pg_catalog"."default",
  "CREATER" varchar(255) COLLATE "pg_catalog"."default",
  "CREATETIME" date,
  "CREATERID" varchar(50) COLLATE "pg_catalog"."default"
)
;

-- ----------------------------
-- Primary Key structure for table DCS_YZYHK_CARD
-- ----------------------------
ALTER TABLE "public"."DCS_YZYHK_CARD" ADD CONSTRAINT "DCS_YZYHK_CARD_pkey" PRIMARY KEY ("ID"); //创建主键

 

你可能感兴趣的:(postgresql,postgresql)