postgresql 常用sql

-- 时间 转 字符串
select to_char(now()::timestamp(0) without time zone, 'YYYY-MM-DD HH24:MI:SS') as date_time_str;
-- 导出表结构
select
col.table_name,
col.column_name,
--col.data_type,
case when col.character_maximum_length is null then  col.udt_name else col.udt_name  || '(' || col.character_maximum_length ||')'end "column_type"
--col.udt_name, 
--col.character_maximum_length,
from
information_schema.columns col 
where
table_schema = 'dbo'
order by table_name, ordinal_position;

 

posted @ 2023-06-15 11:20  PrintY  阅读(5)  评论(0编辑  收藏  举报