SELECT a.tablespace_name "表空间名",
total "表空间大小",
free "表空间剩余大小",
(total - free) "表空间使用大小",
total / (1024 * 1024 * 1024) "表空间大小(G)",
free / (1024 * 1024 * 1024) "表空间剩余大小(G)",
(total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)",
round((total - free) / total, 4) * 100 "使用率 %"
FROM (SELECT tablespace_name, SUM(bytes) free
FROM dba_free_space
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes) total
FROM dba_data_files
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name
-- oracle删除重复数据
delete from t_site a
where a. I_SITE_ID in (select b.I_SITE_ID from t_res_site b group by b.I_SITE_ID having count(b.I_SITE_ID) > 1)
and rowid not in (select min(rowid) from t_res_site b group by b.I_SITE_ID having count(b.I_SITE_ID)>1)
-- 增加表空间大小的四种方法
Meathod1:给表空间增加数据文件
ALTER TABLESPACE app_data ADD DATAFILE
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP03.DBF‘ SIZE 50M;
Meathod2:新增数据文件,并且允许数据文件自动增长
ALTER TABLESPACE app_data ADD DATAFILE
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP04.DBF‘ SIZE 50M
AUTOEXTEND ON NEXT 5M MAXSIZE 100M;
Meathod3:允许已存在的数据文件自动增长
ALTER DATABASE DATAFILE ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP03.DBF‘
AUTOEXTEND ON NEXT 5M MAXSIZE 100M;
Meathod4:手工改变已存在数据文件的大小
ALTER DATABASE DATAFILE ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP02.DBF‘
RESIZE 100M;
--- 创建小文件表空间 (小文件SMALLFILE 单个文件最大30G;)
CREATE SMALLFILE
TABLESPACE "OPENTDB"
LOGGING
DATAFILE ‘+DATA/XXXdb/datafile/db_data01.dbf‘ SIZE 20480M AUTOEXTEND ON NEXT 512M MAXSIZE 30480M,
‘+DATA/XXXdb/datafile/db_data02.dbf‘ SIZE 20480M AUTOEXTEND ON NEXT 512M MAXSIZE 30480M,
‘+DATA/XXXdb/datafile/db_data03.dbf‘ SIZE 20480M AUTOEXTEND ON NEXT 512M MAXSIZE 30480M,
‘+DATA/XXXdb/datafile/db_data04.dbf‘ SIZE 20480M AUTOEXTEND ON NEXT 512M MAXSIZE 30480M,
‘+DATA/XXXdb/datafile/db_data05.dbf‘ SIZE 20480M AUTOEXTEND ON NEXT 512M MAXSIZE 30480M
EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
----核实安装数据库时有没修改默认的帐号密码有效期:
select * from dba_profiles where profile = ‘DEFAULT‘ and resource_name = ‘PASSWORD_LIFE_TIME‘;
oracle 10g的密码没有默认期限,但11g默认只有180天,需要手工调整:
sqlplus / as sysdba
--查看概要文件的密码有效期设置,一般为default
select * from dba_profiles where profile = ‘DEFAULT‘ and resource_name = ‘PASSWORD_LIFE_TIME‘;
--将概要文件的密码有效期由默认的180天修改成无限制,不用重启数据库
alter profile default limit password_life_time unlimited;
--将已经提示ORA_28002警告的用户解锁
alter user 用户名 identified by 密码 account unlock;