postgresql – 选择postgres中的字段的数据类型

前端之家收集整理的这篇文章主要介绍了postgresql – 选择postgres中的字段的数据类型前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何从postgres表中获取特定字段的数据类型?
例如
我有下面的表,
student_details(
stu_id整数,
stu_name varchar(30),
joined_date时间戳
);

在这使用字段名称/或任何其他方式,我需要获得特定字段的数据类型。有什么可能吗?

@H_301_11@
您可以从 information_schema(这里参考的8.4文档,但这不是一个新的功能)获取数据类型:
=# select column_name,data_type from information_schema.columns
-# where table_name = 'config';
    column_name     | data_type 
--------------------+-----------
 id                 | integer
 default_printer_id | integer
 master_host_enable | boolean
(3 rows)
原文链接:https://www.f2er.com/postgresql/193761.html

猜你在找的Postgre SQL相关文章