1. 适用于postgresql数据库
SELECT
'SELECT ' || array_to_string(
ARRAY (
SELECT
'o' || '.' || C.COLUMN_NAME
FROM
information_schema.COLUMNS AS C
WHERE
TABLE_NAME = '表名'
AND C.COLUMN_NAME NOT IN ( '去除字段1','去除字段2' )
),
','
) || ' FROM 表名 As o' AS sqlstmt
网友评论