视频学习Oracle记录
========================================
一、Oracle 数据库操作之用户管理
========================================
0、创建用户:使用Sys或者System 创建用户
sql> create user B identified by w123;--注意的是密码需要以字母开头
1、连接:conn (退出命令 disc)
sql> conn(connect) username/userpassword;
1.1 密码修改
sql> passw
1.2 显示当前用户
sql> show user
1.3 退出
sql> exit
1.4 显示和设置环境变量
sql> linesize: set linesize 90;/ show linesize
pagesize: 用法和linesize
2、授权:权限分为系统权限和对象权限
sql> grant connect to username;
sql> grant connect to username with grant option;--username拥有权限后还可以往下传递权限
以下使用的是对象权限:
2.1 用户A授权给另一个用户B操作A的某一个表
sql> grant select on t_table to B;
sql> grant update on t_table to B;
sql> grant delete on t_table to B;
sql> grant insert on t_table to B;
——若是想要授权以上四种权限则可以使用all的语句
sql> grant all on t_table to B;
2.2 当A授权给B后,B可以使用下面的语句进行查询
sql> select * from A.t_table;
3、收回权限:可以使用关键字revoke
sql> revoke select on t_table from B
4、系统权限授权
system授权给B
sql> grant connect to B with admin option
5、profile管理用户口令
5.1 账户锁定
sql> create profile lock_account limit failed_login_attempts 3 password_lock_time 2;-- 3次2天lock_account为锁的名字
sql> alter user username profile lock_account;
5.2 给用户解锁
sql> alter user username account unlock;
5.3 终止口令
sql> create profile myprofile limit password_life_time 10 password_grace_time 2;--10天 2天的宽限期。12天后口令就失效了。
sql> alter user username profile myprofile;--将myprofile分配给指定用户
5.4 删除profile
drop profile profilename [cascade];--cascade 级联删除
6、文件操作命令
6.1 运行sql脚本
sql> @ c:\a.sql; 或者是 sql> START c:\a.sql;
6.2 edit命令:使用该命令可以编辑sql脚本
sql> edit c:\a.sql;
6.3 使用spool可以讲sqlplus屏幕上的内容输出到指定文本中去
sql> spool c:\b.sql;
sql> spool off;