Oracle创建用户,创建表空间,将空间分配给用户,给用户授权
新建一個表空間,并把它分配給一個用戶就可以了。
以管理員身份登錄的:
查詢當前用戶:
show user;
1.首先,創建(新)用戶:
??? create user username identified by password;
??? username:新用戶名的用戶名
??? password: 新用戶的密碼
也可以不創建新用戶,而仍然用以前的用戶,如:繼續利用scott用戶
?
修改用戶的密碼:
在以SYSDBA身份登陸時可以修改其他用戶的密碼,比如:
SQL> alter user?username identified by password;
用戶已更改。
這個是把USER01用戶密碼修改為USER10
2.創建表空間:
??? create tablespace tablespacename datafile 'd:\data.dbf' size xxxm;
??? tablespacename:表空間的名字
??? d:\data.dbf':表空間的存儲位置
??? xxx表空間的大小,m單位為兆(M)
???? ///---------------------------注意將表空間設成自動擴展的。----------------------------------------------
???? 通過select * from DBA_DATA_FILES可以看到現在數據庫中的表空間和狀態。
其中AUTOEXTENSIBLE為是否自動擴展。 如果需要關閉自動擴展: alter database datafile 'xxx.dbf' autoextend off; 如果需要打開自動擴展??? alter database datafile 'xxx.dbf' autoextend on next 10m [maxsize 500m];
3.將空間分配給用戶:
?? alter user username default tablespace tablespacename;
?? 將名字為tablespacename的表空間分配給username
4.給用戶授權:
?? grant create session to username;--賦予create session的權限,注意這句一定要有
?? grant create table,create view,create trigger, create sequence,create procedure to username;--分配創建表,視圖,觸發器,序列,過程 權限
?? grant unlimited tablespace to username; --授權使用表空間
5.然后再以樓主自己創建的用戶登錄,登錄之后創建表即可。
conn username/password;
?
以下是一個例子:
sqlplus 管理員用戶名/管理員密碼@ip地址:1521/SERVICE_NAME as sysdba;
drop tablespace TS_MISPS including contents and datafiles cascade constraints;
select username,sid,serial# from v$session;
alter system kill session'sid,serial';
drop user MISPS cascade;
create user MISPS identified by MISPS;
select saddr,sid,serial#,paddr,username,status from v$session where username is not null;
create tablespace TS_MISPS datafile 'd:\TS_MISPS.dbf' size 300m;
alter database datafile 'd:\TS_MISPS.dbf' autoextend on next 10m;
alter user MISPS default tablespace TS_MISPS;
grant create session,create table,create view,create trigger, create sequence,create procedure,unlimited tablespace to MISPS;
grant dba to MISPS;
給用戶解鎖
alter user MISPS account unlock;
提交事務
commit
?
如果取消dba的方式
可以做如下修改:
grant connect to 用戶名;
grant resource to 用戶名;
總結
以上是生活随笔為你收集整理的Oracle创建用户,创建表空间,将空间分配给用户,给用户授权的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 很小的青砖墓棺材大,没有墓碑
- 下一篇: 部队文职人员有士官证吗