-mysql
select id,name
from emp
where 1=1
order by case when name='Jim' then 1
when name= 'Joe' then 2
when name = 'Sam' then 3
else name end
-oracle
select * from user_col_comments where table_name = 'BO_EU_KSDA'AND COMMENTS IS NOT NULL
order by
case when comments='客商类别' then '1' --指定显示在第一行
when comments = '客商等级' then '2' --显示指定在第二行
else comments
end
- 查看表名和字段
select COLUMN_NAME, COMMENTS
from user_col_comments
where Table_Name = 'BO_EU_HTQC'
order by case when COMMENTS='合同分类' then '0'
when COMMENTS='合同期限' then '1'
else COMMENTS
end
============================
-- 查询这个用户下所有的表名和表注释
select * from user_tab_comments
-- 查询表名和表中字段和字段的注释
select * from user_col_comments
-- 查询指定表中的字段和注释
select * from user_col_comments where table_name = 'BO_EU_KSDA'AND COMMENTS IS NOT NULL
select COLUMN_NAME, COMMENTS from (
select 1 as o, 'HTBH' as COLUMN_NAME, '合同编号' as COMMENTS from user_col_comments
union
select 2, 'HTJE', '合同金额' from user_col_comments
union
select 3, 'FPSL', '发票税率%' from user_col_comments
union
select 4, 'LYBZJ', '履约保证金' from user_col_comments
union
select 5, 'TGJBL_JE', '团购酒比例/金额' from user_col_comments
union
select 6, COLUMN_NAME, COMMENTS from user_col_comments where Table_Name = 'BO_EU_HTQC' and COMMENTS IS NOT NULL
and COLUMN_NAME not in('HTBH','HTJE','FPSL','LYBZJ','TGJBL_JE')
) t ORDER BY o