Oracle常见操作

前端之家收集整理的这篇文章主要介绍了Oracle常见操作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一些常用到的Oracle数据库操作
本文地址:http://www.jb51.cc/article/p-drgpesas-bpt.html

1 取出分组之后每组前多少条数据

select * from (select name,age row_number() over (partition by name order by age desc) rn from table_name) where rn <10

2 同组数据合并(数据行转列)

select name,wm_concat(distinct age) from (select name,age row_number() over (partition by name order by age desc) rn from table_name) group by name

3 奇数行

select name,age from (select rownum rn,name,age from table_name) where mod(rn,2) = 1;

4 复制表以及表中数据

create table table_name_new as select * from table_name;
-- table_name_new 表存在
insert into table_name_new select * from table_name;
commit;

5 查询表的全部字段及其个数

select wn_concat(column_name) from user_tab_cols where table_name=upper('表名');
select count(*) from user_tab_columns where table_name=upper('表名');
原文链接:https://www.f2er.com/oracle/209742.html

猜你在找的Oracle相关文章