查詢表結構: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;