oracle 知识

来源:互联网 发布:做服装淘宝店铺 编辑:程序博客网 时间:2024/05/22 13:47

sqlplus /  as sysdba;  使用操作系统登录oracle数据库

conn panie/panie;  使用普通用户连接数据库

 

--开启归档模式
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;

shutdown immediate;
startup;
--设置归档空间大小
--alter system set DB_RECOVERY_FILE_DEST_SIZE=20g;

--打开归档日志    
conn / as sysdba;
alter system set log_archive_start=true scope=spfile;

--开启审计     
alter system set audit_sys_operations=TRUE scope=spfile;
alter system set audit_trail=XML scope=spfile;

--开启密码大小写敏感     
alter system set sec_case_sensitive_logon=TRUE;

--global_names加固为true
--alter system set global_names=true scope=spfile;

--os_authent_prefix加固为空字符
alter system set os_authent_prefix='' scope=spfile;

--sql92_security加固为true
alter system set sql92_security=true scope=spfile;

--sec_protocol_error_trace_action加固为log或者alert
alter system set sec_protocol_error_trace_action=log scope=spfile;

--sec_protocol_error_further_action加固为delay,3或者drop,10
alter system set sec_protocol_error_further_action=delay,3 scope=spfile;

--移除XDB服务
alter system set dispatchers='';

--db_securefile加固为always
alter system set db_securefile=always scope=spfile;
--关闭远程连接           
alter system set remote_login_passwordfile=none scope=spfile;

--开启远程连接

alter system set remote_login_passwordfile=exclusive scope=spfile;
shutdown immediate;
startup
修改system初始化参数需要重启生效

show parameters remote_login_passwordfile  查看参数的当前设置

exit  退出数据库

 

grant alter system to panie;  将权限赋给用户panie

revoke alter system from panie;  将权限从用户panie 收回

archive log list;  --查看数据库模式
startup mount; --启动oracle实例,但是不打开数据库
alter database archivelog;  --更改为归档模式
alter database open;  --打开数据库

show parameters db_recovery_file_dest;  -- 设置归档目标

 

 

修改密码策略
ALTER PROFILE DEFAULT LIMIT
PASSWORD_LIFE_TIME 90
PASSWORD_GRACE_TIME 10
PASSWORD_REUSE_TIME 1/144
PASSWORD_REUSE_MAX 6
FAILED_LOGIN_ATTEMPTS 6
PASSWORD_LOCK_TIME UNLIMITED
PASSWORD_VERIFY_FUNCTION verify_function;

 

ALTER PROFILE DEFAULT LIMIT
FAILED_LOGIN_ATTEMPTS UNLIMITED
PASSWORD_LIFE_TIME UNLIMITED
PASSWORD_REUSE_TIME UNLIMITED
PASSWORD_REUSE_MAX UNLIMITED
PASSWORD_VERIFY_FUNCTION NULL
PASSWORD_LOCK_TIME 1
PASSWORD_GRACE_TIME 7;

 

使用sys帐号
create user nie identified by nie;
grant create session,create table to nie;

 

新建的用户要连接数据库必须有create session权限

alter user panie identified by panie;  给用户panie更新密码

alter user panie account unlock; 给用户panie解锁

 

对sql文件中传入变量参数?
调用写好的sql,传入变量
sqlplus /nolog @$INSTALL_HOME/alter_archlog.sql ${sys_username} ${sys_passwd} ${system_username} ${system_passwd}

sql中获取变量
conn /as sysdba;
alter user &1 identified by "&2";
alter user &3 identified by "&4";

或在sh文件中
cat <<HERE >>${filename.sql}
conn / as sysdba
select * from dba_users;
exit;
HERE

create tablespace temp01   --创建一个临时空间
datafile 'd:\Oracle11g\use\use01.dbf' size 10m  --设置表空间文件所在位置、空间大小
reuse   --若是存在则删除后重建
autoextend on   -- 自动扩展
next 10m   -- 每次扩展的大小
maxsize unlimited  --当数据文件是自动扩展时,数据文件可扩展的最大限度
extent management local --所创建的表空间为本地化管理表空间
uniform size 800k  --表空间中盘区大小相同,如果不指定,默认值为64k
[ | autoalllocate ] --盘区大小由oracle自动分配,默认值
segment space management manual  --段的存储管理方式为手动,默认自动auto