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;
grant create session,create table,unlimited tablespace to NAMEMATCHER;
5.然后再以樓主自己創建的用戶登錄,登錄之后創建表即可。
conn username/password;
6.查看服務名
env |grep SID
7.授予dba權限
grant dba to username
7.使用上面的用戶名、密碼、sid登錄plsql
每步執行的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
1.創建用戶
create user user_name identified by "user_password"
default tablespace tbs_name
temporary tablespace temp profile DEFAULT;
2.授權
grant connect to user_name;
grant create indextype to user_name;
grant create job to user_name;
grant create materialized view to user_name;
grant create procedure to user_name;
grant create public synonym to user_name;
grant create sequence to user_name;
grant create session to user_name;
grant create table to user_name;
grant create trigger to user_name;
grant create type to user_name;
grant create view to user_name;
grant unlimited tablespace to user_name;
alter user user_name quota unlimited on tbs_name;
==================================================================
--查詢用戶默認使用的表空間
select username,default_tablespace from dba_users;
--修改默認表空間
alter user TRANSWATCH default tablespace TMS5_TABLES;
--給用戶賦權限
grant create session,create table,unlimited tablespace to TRANSWATCH;
--查詢用戶使用的表空間
select table_name,tablespace_name from user_tables;
--查指定表空間下當前用戶的所有表
select 'alter table '||table_name||' move tablespace TMS5_TABLES;' from
user_tables where tablespace_name = 'USERS';
--批量修改表空間
alter table SANCTIONED_CITIES move tablespace TMS5_TABLES;
...
--查詢索引
select * from user_indexes;
--查指定索引表空間下當前用戶的所有=索引
select 'alter index '||index_name||' rebuild tablespace TMS5_INDEXES;'from user_indexes;
--批量修改索引表空間
alter index SYS_IL0000077055C00004$$ rebuild tablespace TMS5_INDEXES;
alter index PK_SUPPORT_FILES rebuild tablespace TMS5_INDEXES;
...
--查詢函LOB類型表所在索引表空間(ORA-02327: cannot create index on expression with datatype LOB 02327. 00000,報這個錯是因為LOB類型導致)
select * from user_indexes where index_name like 'SYS%'
--表結構
desc SCREENING_IWL_ENTITY;
--移動含LOB類型表的索引到其他表空間
ALTER TABLE SCREENING_IWL_ENTITY MOVE LOB(DETAIL) STORE AS (TABLESPACE TMS5_INDEXES);