登錄管理員最高權限賬號
cmd輸入sqlplus 回車,或者直接打開sqlplus
用戶名:sys
密碼:sys as sysdba
1.首先,創建(新)用戶:
create user username identified by password;
username:新用戶名的用戶名
password: 新用戶的密碼
也可以不創建新用戶,而仍然用以前的用戶,如:繼續利用scott用戶
2.創建表空間:
create tablespace tablespacename datafile 'd:\data.dbf' size xxxm;
tablespacename:表空間的名字
d:\data.dbf':表空間的存儲位置
xxx表空間的大小,m單位為兆(M)
3.將空間分配給用戶:
alter user username default tablespace tablespacename;
將名字為tablespacename的表空間分配給username
4.給用戶授權:
grant create session,create table,unlimited tablespace to username;
5.然后再以樓主自己創建的用戶登錄,登錄之后創建表即可。
conn username/password;
每步執行的sql:(sjzx是數據庫名、用戶名、密碼、表空間名)
(1)create user sjzx identified by sjzx
(2)create tablespace sjzx datafile 'D:\db\app\oradata\orcl\sjzx.dbf' size 100m autoextend on next 32m maxsize 2048m
(3)alter user sjzx default tablespace sjzx
(4)grant create session,create table,unlimited tablespace to sjzx
完整步驟:
--創建兩個數據庫的文件
create tablespace spsy_data
logging
datafile 'D:\orcal11\oradata\orcl\spsy_data.dbf'
size 100m
autoextend on
next 10m maxsize unlimited
extent management local;
create temporary tablespace spsy_temp
tempfile 'D:\orcal11\oradata\orcl\spsy_temp.dbf'
size 100m
autoextend on
next 10m maxsize 500m
extent management local;
--創建用戶與上面創建的文件形成映射關系
create user spsy identified by 000000 default tablespace spsy_data temporary tablespace spsy_temp;
--添加權限
grant connect,resource,dba to spsy;