You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
# 查询数据库相应用户dsideal的所有序列
|
|
|
|
|
SELECT
|
|
|
|
|
*
|
|
|
|
|
FROM
|
|
|
|
|
pg_class
|
|
|
|
|
WHERE
|
|
|
|
|
relowner = (SELECT usesysid FROM pg_user WHERE usename = 'dsideal')
|
|
|
|
|
AND relkind = 'S'
|
|
|
|
|
|
|
|
|
|
# 查询所有表名字,默认schema名字是public
|
|
|
|
|
SELECT
|
|
|
|
|
tablename
|
|
|
|
|
FROM
|
|
|
|
|
pg_tables
|
|
|
|
|
WHERE
|
|
|
|
|
schemaname = 'public'
|
|
|
|
|
|
|
|
|
|
# 查询已知表名tableName的所有字段的字段名、类型、是否为空、注释
|
|
|
|
|
SELECT
|
|
|
|
|
A.attname AS NAME,
|
|
|
|
|
format_type(A.atttypid, A.atttypmod) AS TYPE,
|
|
|
|
|
A.attnotnull AS NOTNULL,
|
|
|
|
|
col_description(A.attrelid, A.attnum) AS COMMENT
|
|
|
|
|
FROM
|
|
|
|
|
pg_class AS C,
|
|
|
|
|
pg_attribute AS A
|
|
|
|
|
WHERE
|
|
|
|
|
C.relname = 'tableName'
|
|
|
|
|
AND A.attnum > 0
|
|
|
|
|
AND A.attrelid = C.oid
|
|
|
|
|
|
|
|
|
|
# 需要注意修改一下
|
|
|
|
|
mysql:ifnull <--> pgsql:coalesce
|