Oracle笔记

查询表结构:ui

select * from user_tab_columns where table_name = '大写表名';

查看表结构&字段注释code

select
	a.column_name,
	b.comments,
	a.DATA_TYPE || '(' || A .DATA_LENGTH || ')' 类型
from
	user_tab_columns a,
	user_col_comments b
where
	a.table_name = '大写表名'
	and a.table_name = b.table_name
	and a.column_name = b.column_name

随机查询 N 条数据:递归

select * from (select * from [表名] order by sys_guid()) where rownum <= N;

递归查询:it

select * from [表名] start with [条件] connect by [子级字段] = prior [父级字段];

🌰【栗子】io

-- 向下递归
select * from organization start with id = 10 connect by parent_id = prior id;
-- 向上递归
select * from organization start with id = 10 connect by id = prior parent_id;
相关文章
相关标签/搜索