常用sql语句由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“常用经典sql语句”。
1、查看表空间的名称及大小
select t.tablespace_name, round(sum(bytes/(1024*1024)),0)ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
2、删除表空间的数据文件:Alter tablespace tablespace_name
Drop datafile file_name;
3、删除表空间:Drop tablespace tablespace_name
[Including contents [And datafiles]]
4、删除表:Drop table table_name[cascade constraints][purge];
4、表空间物理文件的名称及大小
select tablespace_name, file_id, file_name,round(bytes/(1024*1024),0)total_space
from dba_data_files
order by tablespace_name;
5、看控制文件
select name from v$controlfile;
6、看日志文件
select member from v$logfile;
7、查看数据库库对象
select owner, object_type, status, count(*)count#
from all_objects
group by owner, object_type, status;
8、找object为哪些进程所用
select
p.spid,s.sid,s.serial# serial_num,s.username user_name,a.typeobject_type,s.osuser os_user_name,a.owner,a.object object_name,decode(sign(48-command),9、object分类数量
select decode(o.type#,1,'INDEX' , 2,'TABLE' , 3 , 'CLUSTER' , 4, 'VIEW' , 5 ,'SYNONYM' , 6 , 'SEQUENCE' , 'OTHER')object_type , count(*)quantity fromsys.obj$ o where o.type# > 1 group by decode(o.type#,1,'INDEX' , 2,'TABLE' , 3, 'CLUSTER' , 4, 'VIEW' , 5 , 'SYNONYM' , 6 , 'SEQUENCE' , 'OTHER')union select'COLUMN' , count(*)
from sys.col$ union select 'DB LINK' , count(*)from10、哪些数据库实例在运行
select inst_name from v$active_instances;