oracle 常用命令

查看数据库实例
echo $ORACLE_SID
切换数据库实例
export ORACLE_SID=sxmpos
查看数据库当前实例
select name from v$database; 

source .bash_profile 
sqlplus /nolog
conn /as sysdba

startup
quit

lsnrctl start

更改用户密码
alter user ufpmon identified by ufpmon;
查看用户
select username from dba_users;

用户解锁
alter user ufpmon account unlock;
查看用户状态
select username,account_status from dba_users;

授予DBA权限

grant connect,resource,dba to ufpcss;

grant sysdba to ufpcss;

GRANT IMP_FULL_DATABASE to ufpcss;

exp ufpfas/ufpfas2014@DB file=fas1028.dmp log=logname.log statistics =none


查看用户有效时间  SELECT * FROM dba_profiles s WHERE s.profile='DEFAULT' AND resource_name='PASSWORD_LIFE_TIME';

1.select count(*) from v$process;取得数据库目前的进程数。
2.select value from v$parameter where name = 'processes';取得进程数的上限。

启动监听
lsnrctl status

查看用户连接回话
select sid,serial# from v$session where username='UFPCSS'; 
删除连接回话
alter system kill session '30,1918';

删除表、删除用户
DROP USER ufpcss CASCADE;

DROP TABLESPACE ufpcss INCLUDING CONTENTS AND DATAFILES;

创建表空间以及用户并授权
create tablespace ufpcss
  logging datafile '/u01/app/oracle/oradata/db/UFPCSS01.dbf'
  size 300m autoextend on next 100m;

create user ufpcss
  identified by ufpcss
  default tablespace ufpcss;
-- Grant/Revoke role privileges 
grant connect to ufpcss;
grant resource to ufpcss;
grant dba to ufpcss;
-- Grant/Revoke system privileges 

导入数据备份
imp ufpcss/ufpcss@UFPDB full=y file=e:\faccss\ufpcss.dmp ignore=y;
exp ufpcss/ufpcss@UFPDB file=ufpcss_new.dmp


select status from v$instance;  查询数据库状态

alter database datafile'/u01/app/oracle/oradata/db/ufpcrm01.dbf' offline drop; 更改表空间状态为 RECOVER

select name,status,bytes from v$datafile; 查看表空间

alter database open; 将数据库状态变更为 open

将表空间状态更改成离线状态
alter database datafile ufpcrm01.db offline;

配置数据泵路径
create directory dump_dir as '/u01/dump'; 
给用户授权数据泵路径访问权限
grant read,write on directory dump_odir to system; 

查看 process当前连接数量
select * from v$process;















你可能感兴趣的:(oracle,备份,常用命令)