一个数据库可以有多个数据库实例,一个实例可以有多个表空间,一个表空间可以有多张表
创建过程:表空间—>用户—>表
数据库创建用户的步骤:
1.先用系统管理员的账号登陆plsql(使用SYSDBA)
2.再执行脚本
tempfile是临时表空间文件的路径,datafile是表空间的数据文件的路径
查看临时表空间的路径: select * from dba_data_files
将建用户的脚本中的TEMPFILE和DATAFILE中的路径替换为临时表空间的路径
数据库创建用户的脚本:
--删除表空间,以支持重复刷
begin
EXECUTE IMMEDIATE 'DROP TABLESPACE TBS_ASSIST2_TMP INCLUDING CONTENTS AND DATAFILES';
EXCEPTION WHEN OTHERS THEN NULL;
end;
/
--删除数据空间
begin
EXECUTE IMMEDIATE 'DROP TABLESPACE TBS_ASSIST2_DAT INCLUDING CONTENTS AND DATAFILES';
EXCEPTION WHEN OTHERS THEN NULL;
end;
/
CREATE TEMPORARY TABLESPACE TBS_ASSIST2_TMP
TEMPFILE '/data01/oracle/app/oracle/oradata/oracle/assist2db_tmp.dbf' SIZE 1024M REUSE AUTOEXTEND OFF
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 100M;
CREATE TABLESPACE TBS_ASSIST2_DAT
DATAFILE '/data01/oracle/app/oracle/oradata/oracle/assist2db_dat01.dbf' SIZE 2048M AUTOEXTEND OFF
LOGGING
ONLINE
PERMANENT
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
SEGMENT SPACE MANAGEMENT AUTO;
CREATE USER assist2 IDENTIFIED BY "assist2"
DEFAULT TABLESPACE TBS_ASSIST2_DAT
TEMPORARY TABLESPACE TBS_ASSIST2_TMP
PROFILE DEFAULT;
GRANT CONNECT TO assist2;
GRANT RESOURCE TO assist2;
GRANT
CREATE PROCEDURE,
CREATE SYNONYM,
CREATE SEQUENCE,
CREATE TABLE,
CREATE VIEW,
EXECUTE ANY PROCEDURE, FORCE TRANSACTION
TO assist2;
GRANT UNLIMITED TABLESPACE TO assist2;