当前位置:数据库 > SQLServer >>

通过SQL管理表空间、用户、授权

通过SQL管理表空间、用户、授权
 
Sql代码  
--创建表空间  
CREATE TABLESPACE CRMDB  
DATAFILE '/opt/oracle/app/oradata/testdb/crm.dbf' SIZE 500M  
AUTOEXTEND ON NEXT 100M;  
  
--创建用户  
create  user  CRM  identified   by   password  default   tablespace  CRMDB;  
  
--给用户赋权限  
grant  dba  to  CRM;  
  
---删除用户及数据  
drop user CRM cascade;  
 
--修改用户密码  
alter user sys identified by system;  
 
--查看表空间使用情况  
select a.tablespace_name,  
       a.bytes / 1024 / 1024 "Sum MB",  
       (a.bytes - b.bytes) / 1024 / 1024 "used MB",  
       b.bytes / 1024 / 1024 "free MB",  
       round(((a.bytes - b.bytes) / a.bytes) * 100, 2) "percent_used"  
  from (select tablespace_name, sum(bytes) bytes  
          from dba_data_files  
         group by tablespace_name) a,  
       (select tablespace_name, sum(bytes) bytes, max(bytes) largest  
          from dba_free_space  
         group by tablespace_name) b  
 where a.tablespace_name = b.tablespace_name  
 order by ((a.bytes - b.bytes) / a.bytes) desc  
  
 --查看表空间文件地址  
select name from v$datafile;  
 
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,