oracle 一些常用知识
- 操作oralce建议用oracle账户
su -oracle
- sqlplus 客户端工具
用于操作数据库
登录
sqlplus / as sysdba
sqlpuls /nolog
sql> conn system/pwd
sql> quit ! exit 都是退出
3.lsnrctl 监听管理工具
start stop status
services version reload
save_config trace spawn
change_password quit exit
set* show*
4.netmgr 网络配置管理
5.查看指定表空间大小
SELECT TABLESPACE_NAME "表空间",
To_char(Round(BYTES / 1024, 2), '99990.00')
|| '' "实有",
To_char(Round(FREE / 1024, 2), '99990.00')
|| 'G' "现有",
To_char(Round(( BYTES - FREE ) / 1024, 2), '99990.00')
|| 'G' "使用",
To_char(Round(10000 * USED / BYTES) / 100, '99990.00')
|| '%' "比例"
FROM (SELECT A.TABLESPACE_NAME TABLESPACE_NAME,
Floor(A.BYTES / ( 1024 * 1024 )) BYTES,
Floor(B.FREE / ( 1024 * 1024 )) FREE,
Floor(( A.BYTES - B.FREE ) / ( 1024 * 1024 )) USED
FROM (SELECT TABLESPACE_NAME TABLESPACE_NAME,
Sum(BYTES) BYTES
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME) A,
(SELECT TABLESPACE_NAME TABLESPACE_NAME,
Sum(BYTES) FREE
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) B
WHERE A.TABLESPACE_NAME = B.TABLESPACE_NAME)
WHERE TABLESPACE_NAME LIKE 'YZL' --这一句用于指定表空间名称
ORDER BY Floor(10000 * USED / BYTES) DESC;
6.查看指定表空间(tablespace)每个表(table)的大小
SELECT * FROM (SELECT SEGMENT_NAME, SUM(BYTES) / 1024 / 1024 MB FROM
DBA_SEGMENTS WHERE TABLESPACE_NAME = upper('YZL') GROUP BY SEGMENT_NAME
ORDER BY 2 DESC)
需要system用户
7.清空表,删除表并不能清除表占用的存储大小,用下面的语句可以释放
alter table STS_SETTLEMENT move storage(initial 64k)