xiuos_IoT/xiuosiot-backend/dbsql/sql.txt

37 lines
883 B
Plaintext

#新建数据库xiuosiot
create user xiuosiot with password '123456'
#新建用户xiuosiot
create DATABASE xiuosiot with owner =xiuosiot ;
#导出数据字典
SELECT
A.attnum AS "序号",
---C.relname AS "表名",
---CAST ( obj_description ( relfilenode, 'pg_class' ) AS VARCHAR ) AS "表名描述",
A.attname AS "字段名",
A.attnotnull as 是否为空,
--IF(A.attnotnull='f','是','否') AS '必填',
concat_ws ( '-', T.typname, SUBSTRING ( format_type ( A.atttypid, A.atttypmod ) FROM '(.*)' ) ) AS "数据类型",
d.description AS "注释"
FROM
pg_class C,
pg_attribute A,
pg_type T,
pg_description d
WHERE
C.relname = 'user_info'
AND A.attnum > 0
AND A.attrelid = C.oid
AND A.atttypid = T.oid
AND d.objoid = A.attrelid
AND d.objsubid = A.attnum
ORDER BY
C.relname DESC,
A.attnum ASC