oracle语句积累

  1. 修改表数据:update 表名 set 修改内容1,修改内容2… where 条件;
    commit;
  2. 删除表数据:delete from 表名 where 条件;
    commit;
  3. 插入数据:insert into 表名(字段名,字段名…) values(值1,值2…);
    commit;
  4. 删除表:drop table 表名;
  5. 移动表空间:alter table 表名 move tablespace 表空间;
  6. 移动分区表空间:alter table 表名 move partition 分区名 tablespace 表空间名;
  7. 移动索引空间:alter index 索引名 rebuild tablespace 表空间名;
  8. 删除分区:alter table 表名 drop partition 分区名;
  9. 新增分区:alter table 表名 add partion 分区名 values less than(‘20200331’)tablespace 表空间名;
  10. 修改表字段:alter table 表名 modify 字段名 字段类型;
  11. 重命名表字段名:alter table 表名 rename旧字段名 to 新字段名;
  12. 查看索引是否有效,status=valid为有效索引,select * from dba_indexs;
  13. 查看分区数据:select * from 表名 partition(分区名);
  14. 删除某分区数据:alter table tablename truncate partiton 分区名 drop storage;
  15. 压缩表:alter table 表名 move compress;
  16. 压缩分区表:alter table 表名 move partition 分区名 compress;
  17. 压缩索引:alter index 索引名 rebuild compress;
  18. 创建约束:alter table 表名 add constraint 约束名 unique (字段名) ising index tablespace 表空间名;
  19. oracle查看字符集:select userenv(‘language’) from dual;
  20. 数据库服务器字符集环境:select * from nls_database_parameters;查询数据库的字符集设置。
    客户端字符集环境:select * from nls_instance_parameters;查询客户端字符集设置。
    当前会话字符集环境:select * from nls_session_parameters;查询当前会话字符集设置。
  21. listagg() 函数
select phone, listagg(log_name, ',') within group(order by phone) logName
  from int_phone
 where phone = '13350162230'
 group by phone

需要注意的事项如下:
(1). 必须得分组,也就是说group by是必须的。
(2). listagg函数的第一个参数是需要显示的字段,也就是log_name;第二个参数是数值之间的分隔符;同时还需要进行排序和分组within group (order by name)

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值