命令操作oracle数据库总结

命令操作oracle数据库总结

--查询数据库有哪些表空间,以及表空间有多少数据文件、文件的存放地址、数据文件大小
select tablespace_name, file_id, file_name,
  round(bytes/(1024*1024),0) total_space
  from dba_data_files
  order by tablespace_name;

--查询表空间使用情况
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;


--建立主要表空间:ToTest
CREATE TABLESPACE ToTest DATAFILE 'G:\oradata\ToTest\totest02.dbf'
         SIZE 102400M REUSE
         EXTENT MANAGEMENT LOCAL
         SEGMENT SPACE MANAGEMENT AUTO
         ONLINE;


--建立临时表空间ToTest_Temp
CREATE TEMPORARY TABLESPACE ToTest_Temp
TEMPFILE 'G:\oradata\ToTest\ToTest_Temp.dbf' SIZE 10240M;

--扩展表空间数据文件
ALTER TABLESPACE ToTest
  ADD DATAFILE 'G:\oradata\ToTest\totest03.dbf' SIZE 25600M;


--创建用户,并将该数据库用户指定表空间、临时表空间
-- 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;

你可能感兴趣的:(oracle,C++,c,C#)