失效链接处理 |
常用OracleSQL整理 PDF 下载
本站整理下载:
提取码:90ku
相关截图:
主要内容:
--cmd sys登录/退出oracle
sqlplus/nolog;conn/as sysdba;exit
--查看表空间使用情况
select * from dba_tablespace_usage_metrics;
--删除表空间,然后手动删除数据文件物理文件
drop tablespace CRM_F_DATA_TABS including contents and datafiles;
--查看表空间上的用户
select distinct s.owner from dba_segments s where s.tablespace_name ='TBSNAME';
--查看表空间关联数据文件
select t1.name,t2.name from v$tablespace t1,v$datafile t2 where t1.ts#=t2.ts# and t1.name = 'USERS';
--创建表空间
create tablespace test1 datafile 'E:\app\user\oradata\orcl\test1.dbf' size 1000M;
--追加表空间
alter tablespace test1 add datafile 'E:\app\user\oradata\orcl\test2.dbf' size 1000M;
--创建用户
create user hmfms_fx IDENTIFIED BY hmfms_fx default tablespace TBS_DATA temporary tablespace TBS_TEMP profile DEFAULT;
-- Grant/Revoke role privileges
grant connect to hmfms_fx;
grant dba to hmfms_fx;
-- Grant/Revoke system privileges
grant create sequence to hmfms_fx;
grant unlimited tablespace to hmfms_fx;
--查看用户
select * from dba_users;
--删除用户
drop user HMFMS_PJ cascade;
--查看用户进程
select username,sid,serial# from v$session;
--杀进程
alter system kill session'67,508';
1、下面的语句用来查询哪些对象被锁:
select object_name,machine,s.sid,s.serial#
from v$locked_object l,dba_objects o ,v$session s
where l.object_id = o.object_id and l.session_id=s.sid;
2、下面的语句用来杀死一个进程:
alter system kill session '24,111'; (其中24,111分别是上面查询出的sid,serial#)
--创建directory
create directory DIR_HMFMS as 'E:\app\yuminghan\admin\orcl\dpdump';
--查看directory
select * from dba_directories;
--删除directory
drop directory DIR_HMFMS1 ;
--关闭/开启数据库
shutdown immediate; startup;
--导出数据库
expdp hmfms_fx/hmfms_fx@ip:1521/orcl DIRECTORY=bxgjj DUMPFILE=hmfms_fx0425.dmp
--导入数据库
impdp hmfms_fx/hmfms_fx@ORCL directory=DIR_HMFMS dumpfile=hmfms_fx0412.dmp
--导入数据库时用户名表空间不同时,做映射
impdp hmfms_fx/hmfms_fx@ORCL directory=DIR_HMFMS dumpfile=hmfms_fx0412.dmp logfile=crm_hx20180523.log REMAP_SCHEMA=hmfms_panjin:jhmfms_panjin remap_tablespace='EXAMPLE:CRM_F_DATA_TABS,EXAMPLE_TEMP:CRM_F_DATA_TABS_TEMP'
--查询用户所用的表空间,不包含索引
select username,default_tablespace,temporary_tablespace from dba_users where username='CRMPRO';
select owner,table_name,tablespace_name from dba_tables where owner='CRMPRO';
select owner,tablespace_name,count(1) from dba_tables where owner='CRMPRO' group by tablespace_name,owner ;
|