[oracle]經常使用SQL彙總

建立用戶

create user 用戶名 identified by 密碼 default tablespace 默認表空間 temporary tablespace 臨時表空間;oracle

查看錶空間大小

select tablespace_name, sum(bytes)/1024/1024 from dba_data_files group by tablespace_name;ide

查看錶空間及利用率

select a.tablespace_name, total, free, total-free as used from
(select tablespace_name, sum(bytes)/1024/1024 as total from dba_data_files group by tablespace_name) a,
(select tablespace_name, sum(bytes)/1024/1024 as free from dba_free_space group by tablespace_name) b
where a.tablespace_name = b.tablespace_name;spa

表空間擴容

select tablespace_name, file_id, file_name, round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name

alter database datafile '/oracle/oradata/ts_tmp_f01.dbf' resize 2048m索引

查看臨時表空間及利用率

select tablespace_name, tablespace_size/1024/1024 as total, allocated_space/1024/1024 as used, free_space/1024/1024 as free  from dba_temp_free_space;table

查看臨時表空間信息

select * from dba_temp_files;sed

改變表的表空間

alter table 表名 move tablespace 表空間名;file

查看數據目錄

select * from dba_directories;select

查看某表的索引信息

select * from user_indexes where table_name = '表名'密碼

查看錶的列信息

select * from user_tab_columns where table_name='表名'數據

修改列名

alter table 表名 rename column 現列名 to 新列名;

相關文章
相關標籤/搜索