1、使用sys用户登录,连接为SYSDBA;
2、查询表空间数据文件夹在服务器上的路径,得到文件夹的路径为D:\ORACLE\PRODUCT\10.2.0\ORADATA\YWSJ\;
Select FILE_NAME FROM DBA_DATA_FILES;
3、创建表空间
CREATE TABLESPACE TESTSPACE--表空间名称
LOGGING
DATAFILE 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\YWSJ\TESTSPACE.DBF' --指定数据文件路径,该文件会自动生成
SIZE 200M --初始大小
AUTOEXTEND ON
NEXT 32M MAXSIZE UNLIMITED --每次扩展大小
EXTENT MANAGEMENT LOCAL;
4、创建用户并且指定表空间
create user TESTUSER identified by 123456 --指定用户名、密码
default tablespace TESTSPACE--指定默认表空间
temporary tablespace TEMP;--指定临时表空间
5、授予用户权限
grant create session to TESTUSER;--授予用户创建session的权限,即登陆权限
grant unlimited tablespace to TESTUSER;--授予用户使用表空间的权限
grant create any table to TESTUSER;--授予创建表的权限
grant drop any table to TESTUSER;--授予删除表的权限
grant insert any table to TESTUSER;--插入表的权限
grant update any table to TESTUSER;--修改表的权限
grant create any sequence to TESTUSER;
grant create view to TESTUSER;
--授予查询表权限
grant select any table to TESTUSER;
--授予查询字典权限
grant select any dictionary to TESTUSER;
--授予连接、资源、管理员权限
grant connect,resource,dba to TESTUSER;
6、除表空间外的其他数据都删除(删除用户、表、序列、索引、sec)
drop user TESTUSER cascade;
7、导出导入,imp在cmd里面执行,而不是在sqlplus中。可以在客户端执行。
exp TESTUSER/123456@服务器ip/数据库名称 file=F:\TEST0712.dmp owner=(TESTUSER)
imp TESTUSER/123456@服务器ip:1521/数据库名称 file=F:\1\TEST0712.dmp log=F:\1\TEST0712.log full=y ignore=y statistics=none buffer=5400000 commit=y
鸣谢:何瑶龙