oracle 表的导入导出
Posted 霜序0.2℃
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle 表的导入导出相关的知识,希望对你有一定的参考价值。
目的:将scott.emp 表导出 d:\\emp.sql ,删除 emp表并导入emp表
我试了一下exp和imp命令,感觉不太好用
exp
是一个比较古老的命令行工具,用于导出数据,反过来imp
是导入
它导出是这样的,而且编码格式也不知道是啥…
D:\\app\\windows\\product\\11.2.0\\dbhome_1\\BIN>exp scott/你的密码@ORCL file=D:\\emp.sql tables=(emp)
Export: Release 11.2.0.1.0 - Production on 星期一 10月 11 15:03:53 2021
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即将导出指定的表通过常规路径...
. . 正在导出表 EMP导出了 14 行
成功终止导出, 没有出现警告。
D:\\app\\windows\\product\\11.2.0\\dbhome_1\\BIN>exp scott/917356@ORCL file=D:\\emp.sql tables=(emp)
Export: Release 11.2.0.1.0 - Production on 星期一 10月 11 15:04:25 2021
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即将导出指定的表通过常规路径...
. . 正在导出表 EMP导出了 14 行
成功终止导出, 没有出现警告。
D:\\app\\windows\\product\\11.2.0\\dbhome_1\\BIN>
所以我用DataGrip
的导入导出功能来实现目的
连接数据库
导出
点击EMP表,右键导出
下面就是输入到文件里
create table EMP
(
EMPNO NUMBER(4) not null
constraint PK_EMP
primary key,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7, 2),
COMM NUMBER(7, 2),
DEPTNO NUMBER(2)
constraint FK_DEPTNO
references DEPT
)
/
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7369, 'SMITH', 'CLERK', 7902, TO_DATE('1980-12-17', 'YYYY-MM-DD HH24:MI:SS'), 800.00, null, 20);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7499, 'ALLEN', 'SALESMAN', 7698, TO_DATE('1981-02-20', 'YYYY-MM-DD HH24:MI:SS'), 1600.00, 300.00, 30);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7521, 'WARD', 'SALESMAN', 7698, TO_DATE('1981-02-22', 'YYYY-MM-DD HH24:MI:SS'), 1250.00, 500.00, 30);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7566, 'JONES', 'MANAGER', 7839, TO_DATE('1981-04-02', 'YYYY-MM-DD HH24:MI:SS'), 2975.00, null, 20);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7654, 'MARTIN', 'SALESMAN', 7698, TO_DATE('1981-09-28', 'YYYY-MM-DD HH24:MI:SS'), 1250.00, 1400.00, 30);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7698, 'BLAKE', 'MANAGER', 7839, TO_DATE('1981-05-01', 'YYYY-MM-DD HH24:MI:SS'), 2850.00, null, 30);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7782, 'CLARK', 'MANAGER', 7839, TO_DATE('1981-06-09', 'YYYY-MM-DD HH24:MI:SS'), 2450.00, null, 10);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7788, 'SCOTT', 'ANALYST', 7566, TO_DATE('1987-04-19', 'YYYY-MM-DD HH24:MI:SS'), 3000.00, null, 20);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7839, 'KING', 'PRESIDENT', null, TO_DATE('1981-11-17', 'YYYY-MM-DD HH24:MI:SS'), 5000.00, null, 10);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7844, 'TURNER', 'SALESMAN', 7698, TO_DATE('1981-09-08', 'YYYY-MM-DD HH24:MI:SS'), 1500.00, 0.00, 30);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7876, 'ADAMS', 'CLERK', 7788, TO_DATE('1987-05-23', 'YYYY-MM-DD HH24:MI:SS'), 1100.00, null, 20);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7900, 'JAMES', 'CLERK', 7698, TO_DATE('1981-12-03', 'YYYY-MM-DD HH24:MI:SS'), 950.00, null, 30);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7902, 'FORD', 'ANALYST', 7566, TO_DATE('1981-12-03', 'YYYY-MM-DD HH24:MI:SS'), 3000.00, null, 20);
INSERT INTO SCOTT.EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES (7934, 'MILLER', 'CLERK', 7782, TO_DATE('1982-01-23', 'YYYY-MM-DD HH24:MI:SS'), 1300.00, null, 10);
删除
右键删除
导入
用DataGrip自己的也行,在查询控制台直接复制也行,或者直接在命令行底下运行.sql也行
参考:
https://blog.csdn.net/wangchunyu11155/article/details/53635602/
以上是关于oracle 表的导入导出的主要内容,如果未能解决你的问题,请参考以下文章