加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle常见操作

发布时间:2020-12-12 15:04:57 所属栏目:百科 来源:网络整理
导读:一些常用到的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

一些常用到的Oracle数据库操作
本文地址:http://www.52php.cn/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('表名');

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读