[align=center][b][size=medium]命令操作oracle数据库总结[/size][/b][/align]
[b]--查询数据库有哪些表空间,以及表空间有多少数据文件、文件的存放地址、数据文件大小[/b]
select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name;
[b]--查询表空间使用情况[/b]
SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED,c.bytes,(B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE"
FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C
WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;
[b]--建立主要表空间:ToTest[/b]
CREATE TABLESPACE ToTest DATAFILE 'G:\oradata\ToTest\totest02.dbf'
SIZE 102400M REUSE
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO
ONLINE;
[b]--建立临时表空间ToTest_Temp[/b]
CREATE TEMPORARY TABLESPACE ToTest_Temp
TEMPFILE 'G:\oradata\ToTest\ToTest_Temp.dbf' SIZE 10240M;
[b]--扩展表空间数据文件[/b]
ALTER TABLESPACE ToTest
ADD DATAFILE 'G:\oradata\ToTest\totest03.dbf' SIZE 25600M;
[b]--创建用户,并将该数据库用户指定表空间、临时表空间[/b]
-- Create the user
create user ToTest
identified by ""
default tablespace ToTest
temporary tablespace ToTest_Temp
profile DEFAULT;
-- Grant/Revoke role privileges
grant connect to ToTest with admin option;
grant dba to ToTest with admin option;
-- Grant/Revoke system privileges
grant unlimited tablespace to ToTest with admin option;
[b]--查询数据库有哪些表空间,以及表空间有多少数据文件、文件的存放地址、数据文件大小[/b]
select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name;
[b]--查询表空间使用情况[/b]
SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED,c.bytes,(B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE"
FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C
WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;
[b]--建立主要表空间:ToTest[/b]
CREATE TABLESPACE ToTest DATAFILE 'G:\oradata\ToTest\totest02.dbf'
SIZE 102400M REUSE
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO
ONLINE;
[b]--建立临时表空间ToTest_Temp[/b]
CREATE TEMPORARY TABLESPACE ToTest_Temp
TEMPFILE 'G:\oradata\ToTest\ToTest_Temp.dbf' SIZE 10240M;
[b]--扩展表空间数据文件[/b]
ALTER TABLESPACE ToTest
ADD DATAFILE 'G:\oradata\ToTest\totest03.dbf' SIZE 25600M;
[b]--创建用户,并将该数据库用户指定表空间、临时表空间[/b]
-- Create the user
create user ToTest
identified by ""
default tablespace ToTest
temporary tablespace ToTest_Temp
profile DEFAULT;
-- Grant/Revoke role privileges
grant connect to ToTest with admin option;
grant dba to ToTest with admin option;
-- Grant/Revoke system privileges
grant unlimited tablespace to ToTest with admin option;