本文介绍: 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;

原文地址:https://blog.csdn.net/m0_52110974/article/details/135611486

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_56560.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注