首页 > 数据库 >Oracle导入数据

Oracle导入数据

时间:2022-11-29 15:13:50浏览次数:66  
标签:用户 空间 test 导入 tablespace sql Oracle 数据

新建表空间

表空间名字可以先打开sql文件搜索tablespace查看表空间名是什么
image

#在oracle服务器上以sysdba身份登录
sqlplus / as sysdba
#永久表空间创建,datafile可以指定表空间物理文件位置
#大小 500M,每次 5M 自动增大,最大不限制
create tablespace test_tablespace datafile 'testfile.dbf' size 100M autoextend on next 5M maxsize unlimited;
#临时表空间创建
create temporary tablespace test_template_tablespace tempfile 'test_tempfile.dbf' size 10m;

image

新建用户

用户名可以先打开sql文件搜索table查看用户名是什么
image

#新建用户并指定登录密码,同时指定表空间
create user test identified by 123456 default tablespace test_tablespace temporary tablespace test_template_tablespace;

image

高版本的oracle普通用户前面要价c##,如果不带c##可以执行如下命令

alter session set "_ORACLE_SCRIPT"=true;
#新建完用户后再给改回来
alter session set "_ORACLE_SCRIPT"=false;

给用户赋予权限

#给用户赋予权限
grant connect,resource,dba to test;

image

也可以手动给用户指定表空间

# 可以将tablespace表空间分配给指定用户来管理
ALTER USER test QUOTA UNLIMITED ON test_tablespace;
# 指定默认表空间
ALTER USER test DEFAULT TABLESPACE test_tablespace;

登录

#登录测试
conn test/123456;

#查看当前登录用户sql: select user from dual;或者命令
show user
#查看当前用户的表空间
select username,default_tablespace from user_users;
#查看当前实例名
select name from v$database;

#退出登录
exit

image

导入sql

导入sql表结构文件

#sqlplus登录账户
sqlplus test/123456
#导入sql文件,@后面跟着sql文件的路径,回车,导入数据;
@D:/test.sql;
#提交数据
commit;

image
如果导入中文报错ORA-01756: quoted string not properly terminated,参考https://www.cnblogs.com/aeolian/p/16935269.html

导入dmp数据文件

imp "'test/123456  as sysdba'"  file=D:\test.dmp full=y ignore=y;

清除刚才导入的表和数据

https://www.cnblogs.com/aeolian/p/16935456.html

标签:用户,空间,test,导入,tablespace,sql,Oracle,数据
From: https://www.cnblogs.com/aeolian/p/16935162.html

相关文章