1、查看当前open用户
select username,account_status,expiry_date,profile from dba_users;
2、查看目前的密码过期策略
select * from dba_profiles s where s.profile='DEFAULT' and resource_name='PASSWORD_LIFE_TIME';
3、修改密码过期策略
alter profile default limit password_life_time unlimited;
04、过期的账户,重置密码后期不会再过期
$sqlplus / as sysdba
alter user smsc identified by <原来的密码> ----不用换新密码
杀掉进程:
ps -ef | grep LOCAL=NO | grep -v grep | awk '{print $2}'
ps -ef | grep LOCAL=NO | grep -v grep | awk '{print $2}' | xargs kill -9
ps -ef | grep LOCAL=NO | grep -v grep | awk '{print $2}'
ps -ef | grep LOCAL=NO
删除不掉,还是有进程 :
sqlplus
select sid, serial# from v$session where username ='BIP';
SID SERIAL#
---------- ----------
810 3
1099 3
alter system kill session '810,3';
alter system kill session '1099,3';
unzip 压缩包 -d 目标地(目标地由此目录则会覆盖)
导入导出:
create directory DB_BACKUP as '/home/oracle/backup';
select * from dba_directories;
expdp directory=BACKUP schemas=DVUSER_BDS,BIP,ETLUSER dumpfile=bdb_20170623.dmp logfile=bdb_20170623.log compression=all
impdp directory=BACKUP schemas=DVUSER_BDS,BIP,ETLUSER dumpfile=bdb_20170623.dmp logfile=imp_bdb_20170623.log
ALTER PROFILE DEFAULT LIMIT
FAILED_LOGIN_ATTEMPTS 10
PASSWORD_REUSE_MAX unlimited
PASSWORD_REUSE_TIME unlimited
PASSWORD_LOCK_TIME 5/1440
password_verify_function null
password_life_time unlimited;
PASSWORD_REUSE_TIME 密码不能重用前的天数
PASSWORD_REUSE_TIME 密码被重用之前密码改变的次数
alter profile default limit FAILED_LOGIN_ATTEMPTS unlimited;
SQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_REUSE_TIME UNLIMITED;
SQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_REUSE_MAX UNLIMITED;
SQL> ALTER PROFILE DEFAULT LIMIT password_verify_function null;
设置密码永不过期:
alter profile default limit password_life_time unlimited;
建表空间、用户、权限
create tablespace developer datafile '/oradata/TSDB/developer01.dbf' size 1G autoextend on;
create user tsdev identified by tsdev default tablespace developer;
drop user ntp1 cascade;
grant CONNECT to TSBASE;
grant RESOURCE to TSBASE;
grant EXECUTE on SYS.DBMS_LOCK to TSBASE;
grant CREATE PROCEDURE to TSBASE;
grant CREATE VIEW to TSBASE;
grant CREATE SYNONYM to TSBASE;
grant CREATE MATERIALIZED VIEW to NTP1; 物化视图
grant alert session to fis;
grant create database link to tsdeal;
grant unlimited tablespace to monitor;
create user ods identified by ods;
create user tsdev identified by tsdev default tablespace developer;
删除表空间:
drop tablespace CAE_COREDATA including contents and datafiles cascade onstraints;
drop tablespace CAE_COREINDX including contents and datafiles;
查看实例名:
select instance_name from v$instance;
select name from v$database;
select status from v$instance;
添加新的数据文件
alter tablespace temp add tempfile '/oradata/XSWAPDB/temp02.dbf' size 1G autoextend on ;
alter tablespace UNDOTBS1 add datafile '/oradata/rmbtbdb/undotbs02.dbf ' size 100M autoextend on;
alter tablespace temp add tempfile '+DATADG' size 10M autoextend on ;
alter tablespace TS_REPO_DATA add datafile '+DATADG' size 100M autoextend on;
/oradata/basedb/monitorspace01.dbf
alter tablespace MONITORSPACE add datafile '/oradata/basedb/monitorspace02.dbf' size 100M autoextend on ;
offine原有错误的数据文件
alter database tempfile'/oraapp/oracle/oradata/XSWAPDB/temp01.dbf' offline;
删除原有错误的数据文件
alter database tempfile'/oraapp/oracle/oradata/XSWAPDB/temp01.dbf' drop;
查看字符集:
select * from nls_database_parameters;
改密码:
alter user TSDEV identified by Stsdev_sjqy1;
修改服务名:
alter system set service_name='tsdbsvc,TSDB';
解锁用户:
select username,ACCOUNT_STATUS, LOCK_DATE, DEFAULT_TABLESPACE,TEMPORARY_TABLESPACE, PROFILE, CREATED from dba_users order by username;
select username from dba_users;
alter user 用户 account unlock;
alter user 用户 account lock;
查看用户查看表空间:
set linesize 2000
set pagesize 9000
col FILE_NAME for a50
select tablespace_name, file_name ,ceil(BYTES/1024/1024) "BYTES(M)",AUTOEXTENSIBLE,MAXBYTES,INCREMENT_BY ,
ceil(sum(bytes/1024/1024/1024) over (partition by TABLESPACE_NAME order by FILE_NAME rows
between unbounded preceding and unbounded following)) "ALLOCATED(G)",
count(*) over (partition by TABLESPACE_NAME order by FILE_NAME rows
between unbounded preceding and unbounded following)*32 "MAX_ALLOC(G)"
from dba_data_files where tablespace_name like '%&tbs_name%' order by tablespace_name, file_name;
select tablespace_name, file_name ,bytes/1024/1024 file_size,AUTOEXTENSIBLE,MAXBYTES/1024/1024 max from dba_temp_files;
select tablespace_name, file_name ,bytes/1024/1024 file_size,AUTOEXTENSIBLE,MAXBYTES/1024/1024 max from dba_data_files order by TABLESPACE_NAME;
select username,default_tablespace from dba_users;
select TABLESPACE_NAME,STATUS from dba_tablespaces;
查看是否是大文件:
select TABLESPACE_NAME,BIGFILE from dba_tablespaces;
修改临时表空间的大小:
alter database tempfile '+DATADG/xrepodb/tempfile/temp.279.889985887' resize 2G;
alter database tempfile '+DATADG/datawdb/tempfile/temp.382.929965021' autoextend on next 100M maxsize unlimited;
查看某个表创建的时间:
select OWNER,OBJECT_NAME,CREATED,LAST_DDL_TIME from dba_objects where OBJECT_NAME='PVP_CNFRM_MBR_INFO';
查看日志文件的大小:
select distinct(bytes/1024/1024)MB from v$log;
select * from v$log; 查看日志的组和线程
修改日期格式:
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
修改服务的节点:
srvctl config service -d uuasdb 查看服务在哪个节点
srvctl relocate service -d db_unique_name -s 服务名 -i 当前节点 -t 目标节点
srvctl relocate service -d RETDBS -s retdb -i RETDBS1 -t RETDBS2
启动服务的节点:
ora.tsdb.tsdbsvc.svc 1 ONLINE UNKNOWN stsdbs21
[grid@stsdbs21 ~]$ srvctl start service -d tsdb -s tsdbsvc
srvctl start service -d 数据库名 -s 服务名 -n 节点名
srvctl start diskgroup -g dg名称
rac关闭监听:
srvctl stop listener -l 监听名
Usage: srvctl stop listener [-l <lsnr_name>] [-n <node_name>] [-f]
-l <lsnr_name> Listener name
-n <node_name> Node name
-f Force stop
-h Print usage
静默建库:
$ORACLE_HOME/bin/dbca -silent -createDatabase -templateName /home/oracle/fxmss.dbt \
-gdbName fxmss -sid fxmss -sysPassword Pass#123 -systemPassword Pass#123 -storageType FS \
-datafileJarLocation $ORACLE_HOME/assistants/dbca/templates
静默删库:
dbca -silent -deleteDatabase -sourceDB FXCSTPDB
关闭数据库:
srvctl stop database -d datawdb -o immediate
srvctl start database -d datawdb -o immediate
关闭数据库实例:
su - grid
srvctl stop instance -d kobra -i kobra1
srvctl start instance -d kobra -i kobra1
计划任务:
export EDITOR=vi solaris需要设置
0 * * * * . /export/home/oracle/.profile; /export/home/oracle/bin/common/delArch LCM2DBS 1 1> /tmp/delArch_LCM2DBS.log 2>&1
0 * * * * . /home/oracle/.bash_profile; /home/oracle/bin/common/delArch PPPSDB 1 1> /tmp/delArch_PPPSDB.log 2>&1
0 0 * * * find /oraapp/oracle/admin/kobra/adump -name '*.aud' -mtime +30 | xargs -i rm -rf {}
12c
alter session set container = xpedb;
alter pluggable database open;
0 * * * * /home/oracle/bin/common/delArch comstar 1 1> /tmp/delArch_comstar.log 2>&1
5 15 * * * . /home/oracle/.bash_profile; /home/oracle/bin/common/delArch CIMDB 1 1> /tmp/delArch_CIMDB.log 2>&1
create spfile from pfile='/tmp/ntp1db.ora';
解压:
tar -xzf v9.7fp7_linuxx64_server.tar.gz
gunzip scripts.20140310.tar.gz
tar xvf scripts.20140310.tar
删除回收站:
purge dba_recyclebin;
nas服务器:
scp -r 12.2.0.1.8 [email protected]:./20171024
1、查看当前open用户
select username,account_status,expiry_date,profile from dba_users;
2、查看目前的密码过期策略
select * from dba_profiles s where s.profile='DEFAULT' and resource_name='PASSWORD_LIFE_TIME';
3、修改密码过期策略
alter profile default limit password_life_time unlimited;
04、过期的账户,重置密码后期不会再过期
$sqlplus / as sysdba
alter user smsc identified by <原来的密码> ----不用换新密码