【发布时间】:2021-03-28 05:07:52
【问题描述】:
需要通过截断然后使用转储文件再次填充表来频繁更新表。这样做时,我首先删除了引用键。这减少了填充表的时间。我可以检索以下类似的输出,即使用 Java JDBC 的表的 DDL?我尝试了 DatabaseMetaData 方法来获取表的 DDL,但没有找到可以做到这一点的有用方法。
health=# \d system_user
Table "public.system_user"
| Column | Type | Collation | Nullable | Default |
|--------------+------------------------+-----------+----------+---------|
| user_id | bigint | | not null | |
| email | character varying(255) | | not null | |
| first_name | text | | not null | |
| last_name | text | | not null | |
| password | character varying(255) | | not null | |
| phone_number | character varying(255) | | not null | |
| provider_id | bigint | | | |
Indexes:
"system_user_pkey" PRIMARY KEY, btree (user_id)
Foreign-key constraints:
"fka48037dbd736797" FOREIGN KEY (provider_id) REFERENCES provider(provider_id)
Referenced by:
TABLE "annotation_project_annotator" CONSTRAINT "annotation_project_annotator_fk_1" FOREIGN KEY (annotator) REFERENCES system_user(user_id) ON DELETE RESTRICT
TABLE "annotation_project" CONSTRAINT "annotation_project_fk_2" FOREIGN KEY (supervisor) REFERENCES system_user(user_id) ON DELETE RESTRICT
TABLE "annotation_project" CONSTRAINT "annotation_project_fk_3" FOREIGN KEY (created_by) REFERENCES system_user(user_id) ON DELETE RESTRICT
TABLE "annotation_project" CONSTRAINT "annotation_project_fk_4" FOREIGN KEY (updated_by) REFERENCES system_user(user_id) ON DELETE RESTRICT
TABLE "grammar" CONSTRAINT "fk10b467a7b7ea696d" FOREIGN KEY (user_id) REFERENCES system_user(user_id)
TABLE "manual_annotation" CONSTRAINT "fk2a02e148b7ea696d" FOREIGN KEY (user_id) REFERENCES system_user(user_id)
【问题讨论】:
标签: postgresql jdbc ddl database-metadata