oracle建表空间、用户
建表空间
语法:create tablespace tablespace_name datafile datafile_path size 2048M autoextend on;
tablespace_name:表空间的名称
datafile_path:数据文件的存储路径,必须有读写的权限,可以用chmod设置
size:表空间大小
举例:create tablespace oacloud datafile '/oracle_data_file/oacloud.dbf' size 2048M;
建用户
语法:create user user_name identified by user_pwd default tablespace tablespace_name;
user_name:用户名
user_pwd:用户密码
tablespace_name:上一步建的表空间
举例:create user dtoa identified by dtoa default tablespace oacloud;
给用户授权
grant connect,resource to dtoa;
grant dba to dtoa;
查看表空间
SELECT T.TABLESPACE_NAME, ROUND(SUM(BYTES / (1024 * 1024)), 0) TS_SIZE
FROM DBA_TABLESPACES T, DBA_DATA_FILES D
WHERE T.TABLESPACE_NAME = D.TABLESPACE_NAME
GROUP BY T.TABLESPACE_NAME;
查看表空间物理文件地址
SELECT TABLESPACE_NAME,
FILE_ID,
FILE_NAME,
ROUND(BYTES / (1024 * 1024), 0) TOTAL_SPACE
FROM DBA_DATA_FILES
ORDER BY TABLESPACE_NAME;
删除表空间
drop tablespace MID_DATA including contents and datafiles
数据文件被服务占用所以删不掉,停掉服务再删除。