Oracle常见操作

知识点1:格式化日期

select to_char(sysdate,'yyyy-MM-dd HH:mm:ss') as time from dual;

运行截图:
在这里插入图片描述
知识点2:解锁用户

alter user test account unlock;

知识点3:修改密码

alter user test identified by test2;

知识点4:修改表名

alter table tbname rename to tbname2;

知识点5:Oracle导出指定表

expdp test/test tables=tb1,tb2,tb3 directory=DIR dumpfile=test.dmp

知识点6:创建索引

create index idx_test on tb(name,fcreatetime);

知识点7:金额只保留数字

round(nvl(regexp_replace(money,'[^0-9.]',''),0),2) as fje

知识点8:修改字段类型

	>alter table tb add tmp_col TIMESTAMP; -- 添加临时列
	>update tb set tmp_col=FCREATETIME; -- 将目标字段中数据加入到临时列中
	>update tb set FCREATETIME=null; -- 将目标字段数据清空
	>alter table tb modify (FCREATETIME varchar2(100)); -- 更改目标字段类型
	>update tb set FCREATETIME=to_char(tmp_col,'yyyy-mm-dd'); -- 将临时列数据加回到目标字段中
	>alter table tb drop column tmp_col; -- 清除临时列

知识点9:将密码设置为永久有效

1.登录
>sqlplus / as sysdba
2.查看用户的profile是哪个,一般为default
>select username,profile from dba_users 
3.查看对应的概要文件(default)的密码有效期(默认180)
>select * from dba_profiles s where s.profile='DEFAULT' and resource_name='PASSWORD_LIFE_TIME'
4.将profile密码设置为永久
>alter profile DEFAULT LIMIT PASSWORD_LIFE_TIME unlimited;
5.无需重启即可生效

知识点10:Oracle从其他表导入相同字段值到当前表

insert into B_T_HYXXS(FHYML,FHYDL) select fhyml,fhydl from b_t_hyxx;

本人正在打造技术交流群,欢迎志同道合的朋友一起探讨,一起努力,通过自己的努力,在技术岗位这条道路上走的更远。QQ群号:914683950 备注:技术交流 即可通过!

  • 6
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值