正文

postgresql 删除重复数据案例详解(post的用法搭配)居然可以这样

文章摘要

这篇文章描述了在PostgreSQL数据库中对“public”数据库中的“test”表进行的一系列操作。主要内容包括:1)删除现有“test”表,2)创建新的“test”表,包含三个字段(id、name和age),其中“id”为主键字段,3)插入五条测试数据,4)定义“test”表的主键约束。这些操作展示了如何在PostgreSQL中进行基本的表操作和数据管理。

 — —————————- — Table structure for test — —————————- DROP TABLE IF EXISTS “public”.”test”; CREATE TABLE “public”.”test” ( “id” int4 NOT NULL DEFAULT NULL, “name” varchar(255) COLLATE “pg_catalog”.”default” DEFAULT NULL, “age” int4 DEFAULT NULL ) ; — —————————- — Records of test — —————————- INSERT INTO “public”.”test” VALUES (1, ‘da’, 1); INSERT INTO “public”.”test” VALUES (2, ‘da’, 12); INSERT INTO “public”.”test” VALUES (3, ‘dd’, 80); INSERT INTO “public”.”test” VALUES (4, ‘dd’, 80); INSERT INTO “public”.”test” VALUES (5, ‘d1’, 13); — —————————- — Primary Key structure for table test — —————————- ALTER TABLE “public”.”test” ADD CONSTRAINT “test_pkey” PRIMARY KEY (“id”);