C/C++教程

oracle新建表空间和用户并赋权限

本文主要是介绍oracle新建表空间和用户并赋权限,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1. 查看表空间路径

SELECT
    a.file#,
    a.name,
    a.bytes / 1024 / 1024                          currentmb,
    ceil(hwm * a.block_size / 1024 / 1024)         resizeto,
    ( a.bytes - hwm * a.block_size ) / 1024 / 1024 releasemb,
    'alter database datafile '''
    || a.name
    || ''' resize '
    || ceil(hwm * a.block_size / 1024 / 1024)
    || 'M;'                                        resizecmd
FROM
    v$datafile a,
    (
        SELECT
            file_id,
            MAX(block_id + blocks - 1) hwm
        FROM
            dba_extents
        GROUP BY
            file_id
    )          b
WHERE
    a.file# = b.file_id (+)
    AND ( a.bytes - hwm * a.block_size ) > 0
ORDER BY
    5;

2.查看表空间数据

SELECT
    *
FROM
    dba_users;

3.新建表空间

CREATE TABLESPACE sanhua_qg
DATAFILE 'C:\ORACLE\ORADATA\ORCL\QG01.DBF' size 800M
         EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

4.新建用户并授权

--创建用户
create user qinggang identified by sanhua;
--修改用户默认表空间
alter user qinggang default tablespace sanhua_qg;
--或者创建用户并设置默认表空间
create user qinggang identified by sanhua
default tablespace sanhua_qg;
--赋权限
grant connect,resource to qinggang;
grant create any sequence to qinggang;
grant create any table to qinggang;
grant delete any table to qinggang;
grant insert any table to qinggang;
grant select any table to qinggang;
grant unlimited tablespace to qinggang;
grant execute any procedure to qinggang;
grant update any table to qinggang;
grant create any view to qinggang;
--或者赋DBA权限
grant connect,resource,dba to qinggang;
这篇关于oracle新建表空间和用户并赋权限的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!