postgresql数据库查看表信息

SELECT
	C .relname AS table,
	d .description as  tablename
FROM
	pg_class C,
	pg_description d
WHERE
	C .oid = d.objoid
AND d.objsubid = '0'
AND d.description LIKE '%表%';


SELECT
	d.objsubid,
	C .relname,
	NULL AS datatype,
	NULL AS datalength,
	d.description
FROM
	pg_description d,
	pg_class C
WHERE
	d.objoid = C .oid
AND C .relname = 't_con_resource_theme'
AND objsubid = '0'
UNION ALL
	(
		SELECT
			col.ordinal_position AS objsubid,
			col. COLUMN_NAME AS relname,
			col.data_type AS datatype,
			col.character_maximum_length AS datalength,
			des.description
		FROM
			information_schema. COLUMNS col
		LEFT JOIN pg_description des ON col. TABLE_NAME :: regclass = des.objoid
		AND col.ordinal_position = des.objsubid
		WHERE
			TABLE_NAME = 't_con_resource_theme'
		ORDER BY
			col.ordinal_position
	);

你可能感兴趣的:(postgresql)