时间:2021-07-01 10:21:17 帮助过:11人阅读
通过pl/sql登录到Oracle数据库上,然后执行菜单:文件/新建/命令窗口 ,打开一个命令窗口然后在该命令窗口中执行脚本创建和删除表空间
创建表空间
create tablespace db_name_
datafile ‘D:\oracle\product\10.2.0\oradata\orcl\db_name_.dbf‘ size 200M
autoextend on next 10M maxsize unlimited logging
extent management local autoallocate
segment space management auto;
1) DATAFILE: 表空间数据文件存放路径
2) SIZE: 起初设置为200M
3) UNIFORM: 指定区尺寸为128k,如不指定,区尺寸默认为64k
4) 空间名称:db_name_ 与 数据文件名称 db_name_.dbf 不要求相同,可随意命名.
5) AUTOEXTEND ON/OFF 表示启动/停止自动扩展表空间
6) alter database datafile ‘ D:\oracle\product\10.2.0\oradata\orcl\db_name_.dbf ‘ resize 500m; //手动修改数据文件大小为500M
7) DROP TABLESPACE db_name_ INCLUDING CONTENTS AND DATAFILES; //删除表空间
测试创建表空间
create tablespace IMSTEST
datafile ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\HNORCL\IMTEST.def‘ size 200M
autoextend on next 20M maxsize unlimited logging
extent management local autoallocate
segment space management auto;
commit;
创建用户,设置DBA角色
CREATE USER MARTIN -----用户名
IDENTIFIED BY martinpwd ------密码
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP;
例如:
--创建新用户
CREATE USER jack
IDENTIFIED BY "123"
DEFAULT TABLESPACE "USERS"
TEMPORARY TABLESPACE "TEMP"
grant connect to jack ; -----授权
grant dba to jack ;
grant sysdba to jack ;
//删除用户
drop user jack cascade;
[Oracle 10g]-关于表空间的更名
SQL> COL FILE_NAME format a70
SQL> SET linesize 120
SQL> SET pagesize 99
SQL> COL TABLESPACE_NAME format a10
SQL>
SQL> SELECT file_name, tablespace_name FROM dba_data_files;
删除用户名字
drop user PROJECTNAME cascade;
create tablespace TBS_PROJECTNAMETEST datafile ‘D:\tbs_PROJECTNAME_test.dbf‘ size 20000M autoextend on next 1000M maxsize unlimited logging extent management local autoallocate segment space management auto;
CREATE USER PROJECTNAME
IDENTIFIED BY "PROJECTNAME"
DEFAULT TABLESPACE "TBS_PROJECTNAMETEST"
TEMPORARY TABLESPACE "TEMP" ;
grant connect to PROJECTNAME ;
grant dba to PROJECTNAME ;
grant sysdba to PROJECTNAME ;
---------------------------------------------------------------------------------------------------------------------------------
---创建表空间
--数据空间
create tablespace PSHRDATA datafile ‘F:\app\42210/PSHRDATA.DBF‘ size 5000 M AUTOEXTEND ON ONLINE ;
--创建临时表空间
create TEMPORARY tablespace PSHRTMP TEMPFILE ‘F:\app\42210/PSHRDATA.DBF‘ size 900M AUTOEXTEND ON ;
--创建数据库连接用户
create user PSHR
identified by PSHR2016----密码根据实际自由设定
default tablespace PSHRDATA--表空间名
temporary tablespace PSHRTMP--临时表空间名
profile DEFAULT;
-- Grant/Revoke role privileges--给用户授权
grant connect to PSHR with admin option;
grant dba to PSHR with admin option;
grant resource to PSHR with admin option;
-- Grant/Revoke system privileges
grant unlimited tablespace to PSHR with admin option;
--在cmd中找到安装路径F:\app\42210\product\11.2.0\dbhome_1\BIN 导入数据库
imp PSHR/PSHR2016@orcl full=y file=F:\PSHR_EXP.dmp log=F:\tables.log ignore=y;
添加权限
CREATE OR REPLACE DIRECTORY dump_dir AS ‘F:\‘;
Grant read,write on DIRECTORY dump_dir to PSHR;
impdp PSHR/PSHR2016@ORCL DIRECTORY=dump_dir DUMPFILE=djzdb.dmp
来到新公司不让共享数据库大家用各自的,自然得安装oracle,在plsql里面创建表空间导入表等,这是同事提供的资料
plsql表空间的建立即相关问题
标签:size cto end 空间 bho limited 添加权限 profile file