Oracle创建和配置用户

创建用户,并为用户分配适当的概要文件和角色。可采取调用企业管理器数据库Express,以DBA1用户和SYSDBA登录后进行创建。但需要处理批量创建任务时,此方法并非高效。

另一种办法可以通过Oracle自带的gedit Text Editor创建一个sql脚本,具体指令为:

create user "&&username" identified by newuser profile "HRPROFILE" password expire account unlock default tablespace "USERS" temporary tablespace "TEMP";

grant “&&role” to “&&username”;

grant "CONNECT" to “&&username”;

保存名称为P6script.sql文件,保存位置为/home/oracle/P6script.sql

运行P6script.sql文件,使用下面代码:

sqlplus dba1/oracle_4U as sysdba @/home/oracle/P6script.sql

 根据提示输入需要创建的用户名(JGOODMAN)和角色(HRMANAGER):

[oracle@12c-env Desktop]$ sqlplus dba1/oracle_4U as sysdba @/home/oracle/P6script.sql

SQL*Plus: Release 12.1.0.2.0 Production on Sat Aug 13 15:52:33 2022

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

Enter value for username: JGOODMAN
old   1: create user "&&username" identified by newuser profile "HRPROFILE" password expire account unlock default tablespace "USERS" temporary tablespace "TEMP"
new   1: create user "JGOODMAN" identified by newuser profile "HRPROFILE" password expire account unlock default tablespace "USERS" temporary tablespace "TEMP"

User created.

Enter value for role: HRMANAGER
old   1: grant "&&role" to "&&username"
new   1: grant "HRMANAGER" to "JGOODMAN"

Grant succeeded.

old   1: grant "CONNECT" to "&&username"
new   1: grant "CONNECT" to "JGOODMAN"

Grant succeeded.

SQL> connect jgoodman
Enter password: 
ERROR:
ORA-28001: the password has expired


Changing password for jgoodman
New password: 
Retype new password: 
Password changed
Connected.

备注:创建好用户后,首次登陆时需更改口令,默认口令为newuser

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值