selectt1.ordinal_position,-- 字段排序号t1.relkind,-- 表类型。v视图,r实体表,p分区表t1.table_schema,-- 模式名split_part(t1.description,'。',1)astable_name,-- 表名t1.table_nameastable_code,-- 表代码t1.description,-- 表描述split_part(t1.comment,'。',1)ascolumn_name,-- 字段代码t1....
ORDER BY col.table_name, col.ordinal_position; 复制代码
SELECT column_name, ordinal_position FROM information_schema.columns WHERE table_name = 'table_name' ORDER BY ordinal_position; 这将返回指定表中各列的名称及其在表中的位置(即顺序)。 字段顺序对数据库性能和查询的影响 在大多数情况下,字段顺序对数据库性能和查询结果的影响可以忽略不计。然而,在以下情...
COALESCE("parameters".parameter_name, '') || ' ' || COALESCE("parameters".udt_name, '') AS params, "parameters".ordinal_position FROM "information_schema"."routines" LEFT JOIN "information_schema"."parameters" ON "routines".specific_name="parameters".specific_name WHERE "routines".specific_...
"parameters".ordinal_positionFROM"information_schema"."routines"LEFTJOIN"information_schema"."parameters"ON"routines".specific_name="parameters".specific_nameWHERE"routines".specific_schema='abc'ORDERBY1,2,6; AI代码助手复制代码 这里我们再使用聚合函数: string_agg 把字段 params所有行连接成字符串,并用...
ordinal_position WHERE col.table_schema = 'test_schema' AND description IS NULL ORDER BY col.table_name, col.ordinal_position; 参考: http://postgres.cn/docs/12/catalog-pg-class.html http://postgres.cn/docs/12/catalog-pg-description.html http://postgres.cn/docs/12/sql-comment.html 本文...
and col.ordinal_position = des.objsubid where table_schema = 'public' and table_name = 't_student' order by ordinal_position; 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 或者简单点: ...
在PostgreSQL中显示表格的结构和内容,可以使用SQL语句进行查询。 首先,使用以下SQL语句来显示表格的结构: 代码语言:txt 复制 SELECT column_name, data_type, character_maximum_length, column_default FROM information_schema.columns WHERE table_name = 'your_table_name' ORDER BY ordinal_position; 其中,your_ta...
COMMENT ON COLUMN public.tb_car.car_id IS '主键'; COMMENT ON COLUMN public.tb_car.car_index_code IS '车辆编码'; COMMENT ON COLUMN public.tb_car.plate_no IS '车牌号码'; 用如下语句查询 SELECT col.table_name, col.column_name, col.ordinal_position AS o, d.description FROM information_...
table_catalog, table_schema, table_name, column_name, ordinal_position, is_nullable, data_type等 查询测试表的字段信息: select*frominformation_schema.columnswheretable_schema='schema2023'andtable_name='some_info' 结果: ben发布于博客园 综合查询:包括字段注释 ...