plsql基本操作 复制表 导出表 导出表结构 及其导入
上一片中介绍了安装instantclient +plsql取代庞大客户端的安装,这里说下plsql的基本操作
plsql操作界面图:

1、复制表
语句:create table IGIS_COPY as select * from IGIS_LOCATION
2、查询前5行数据
select * from IGIS_LOCATION where rownum < 6
注意:与sql server的top 5 不同,前5行数据只能使用where rownum < 6
导出查询出来的数据。注意是.sql文件

下面是用txt打开上面导出的.sql文件,其原理是是对数据库进行insert
下面的数据表是
IGIS_LOCATION_COPY,是我将上面的
IGIS_LOCATION备份了一份,进行操作
prompt Importing table IGIS_LOCATION_COPY...
set feedback off
set define off
insert into IGIS_LOCATION_COPY (DEVICECODE, TYPE, LONGITUDE, LATITUDE, DATETIME)
values ('001FF92FABE165', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss')); insert into IGIS_LOCATION_COPY (DEVICECODE, TYPE, LONGITUDE, LATITUDE, DATETIME)
values ('004999010640000', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss')); insert into IGIS_LOCATION_COPY (DEVICECODE, TYPE, LONGITUDE, LATITUDE, DATETIME)
values ('012963007793321', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss')); insert into IGIS_LOCATION_COPY (DEVICECODE, TYPE, LONGITUDE, LATITUDE, DATETIME)
values ('013437006991011', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss')); insert into IGIS_LOCATION_COPY (DEVICECODE, TYPE, LONGITUDE, LATITUDE, DATETIME)
values ('013789000795180', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss')); prompt Done.
3、导出整个表
右击表,点导出数据(或者单击工具--导出表)
选择第二个“SQL插入”,注意要选上:创建表,否者导出的.sql文件没有表结构,无法使用下一步中的“导入表”方法导入。

导出的.sql文件
prompt PL/SQL Developer import file
prompt Created on 2017年5月3日 by Administrator
set feedback off
set define off
prompt Creating IGIS_LOCATION_COPY...
create table IGIS_LOCATION_COPY
(
devicecode VARCHAR2(50) not null,
type VARCHAR2(10) not null,
longitude NUMBER(10,2) not null,
latitude NUMBER(10,2) not null,
datetime DATE not null
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
); prompt Disabling triggers for IGIS_LOCATION_COPY...
alter table IGIS_LOCATION_COPY disable all triggers;
prompt Deleting IGIS_LOCATION_COPY...
delete from IGIS_LOCATION_COPY;
commit;
prompt Loading IGIS_LOCATION_COPY...
insert into IGIS_LOCATION_COPY (devicecode, type, longitude, latitude, datetime)
values ('001FF92FABE165', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss'));
insert into IGIS_LOCATION_COPY (devicecode, type, longitude, latitude, datetime)
values ('004999010640000', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss'));
insert into IGIS_LOCATION_COPY (devicecode, type, longitude, latitude, datetime)
values ('012963007793321', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss'));
insert into IGIS_LOCATION_COPY (devicecode, type, longitude, latitude, datetime)
values ('013437006991011', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss'));
insert into IGIS_LOCATION_COPY (devicecode, type, longitude, latitude, datetime)
values ('013789000795180', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss'));
insert into IGIS_LOCATION_COPY (devicecode, type, longitude, latitude, datetime)
values ('014583569411', 'car', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss'));
insert into IGIS_LOCATION_COPY (devicecode, type, longitude, latitude, datetime)
values ('049955', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss'));
insert into IGIS_LOCATION_COPY (devicecode, type, longitude, latitude, datetime)
values ('050846', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss'));
insert into IGIS_LOCATION_COPY (devicecode, type, longitude, latitude, datetime)
values ('050853', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss'));
insert into IGIS_LOCATION_COPY (devicecode, type, longitude, latitude, datetime)
values ('050859', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss'));
commit;
prompt 10 records loaded
prompt Enabling triggers for IGIS_LOCATION_COPY...
alter table IGIS_LOCATION_COPY enable all triggers;
set feedback on
set define on
prompt Done.
4、导入整张表
单击 “工具”--“导入表”
SQL*Plus就是上一篇博文中介绍的下载了sqlplus,如果安装的时候没下载,参考上篇
http://www.cnblogs.com/lelehellow/p/6801800.html

5、导出表结构
单击 “工具”--“导出用户对象”
记得选中表

使用上一步中的“导入表”方法来导入这个.sql文件可以导入一张空表,表结构还是跟这张表一样的。
打开导出的用户对象 .sql文件,发现其实就是导出了创建表的sql语句。
----------------------------------------------------
-- Export file for user SYSTEM --
-- Created by Administrator on 2017-5-3, 13:09:02 --
---------------------------------------------------- set define off
spool guanxi.log prompt
prompt Creating table IGIS_LOCATION_COPY
prompt =================================
prompt
create table SYSTEM.IGIS_LOCATION_COPY
(
devicecode VARCHAR2(50) not null,
type VARCHAR2(10) not null,
longitude NUMBER(10,2) not null,
latitude NUMBER(10,2) not null,
datetime DATE not null
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
); spool off
6、使用“导入表”功能来导入第二步中导出的前5行数据
使用“导入表”功能来导入第二步中导出的前5行数据(.sql文件),发现导入无效。而第三步和第五步中同样是.sql文件,使用“导入表”功能都可以导入。
对边上面的.sql文件发现,其原因在于第二步中导出的.sql文件中没有定义表结构,也就是没有创建表。将其中的insert语句复制到第五步中的表结构sql文件中,就可以实现导入表了。
这样导入的表也就是只有原表中前5行数据的表了。
处理后的.sql文件如下:
----------------------------------------------------
-- Export file for user SYSTEM --
-- Created by Administrator on 2017-5-3, 13:09:02 --
---------------------------------------------------- set define off
spool guanxi.log prompt
prompt Creating table IGIS_LOCATION_COPY
prompt =================================
prompt
create table SYSTEM.IGIS_LOCATION_COPY
(
devicecode VARCHAR2(50) not null,
type VARCHAR2(10) not null,
longitude NUMBER(10,2) not null,
latitude NUMBER(10,2) not null,
datetime DATE not null
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
); insert into IGIS_LOCATION_COPY (DEVICECODE, TYPE, LONGITUDE, LATITUDE, DATETIME)
values ('001FF92FABE165', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss')); insert into IGIS_LOCATION_COPY (DEVICECODE, TYPE, LONGITUDE, LATITUDE, DATETIME)
values ('004999010640000', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss')); insert into IGIS_LOCATION_COPY (DEVICECODE, TYPE, LONGITUDE, LATITUDE, DATETIME)
values ('012963007793321', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss')); insert into IGIS_LOCATION_COPY (DEVICECODE, TYPE, LONGITUDE, LATITUDE, DATETIME)
values ('013437006991011', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss')); insert into IGIS_LOCATION_COPY (DEVICECODE, TYPE, LONGITUDE, LATITUDE, DATETIME)
values ('013789000795180', 'man', 121.12, 31.12, to_date('26-04-2017 14:29:05', 'dd-mm-yyyy hh24:mi:ss')); spool off
7、注意:假如发现自己使用plsql导出的表无法导入,极可能是因为在导出表的时候没有选上“创建表”这一项。上一步中的介绍可猜测,在导出前5行数据的时候,默认的没有创建表。

挂两个外链,管理员请不要删我文,如违规可联系我自行修改删除,QQ:919497132
plsql基本操作 复制表 导出表 导出表结构 及其导入的更多相关文章
- sql developer Oracle 数据库 用户对象下表及表结构的导入导出
Oracle数据库表数据及结构的导入导出 导出的主机与即将导入到的目标主机的tablespace 及用户名需一直!!!!!
- Oracle中如何导出存储过程、函数、包和触发器的定义语句?如何导出表的结构?如何导出索引的创建语句?
Oracle中如何导出存储过程.函数.包和触发器的定义语句?如何导出表的结构?如何导出索引的创建语句? QQ群里有人问:如何导出一个用户下的存储过程? 麦苗答:方法有多种,可以使用DBMS_MET ...
- 小甲鱼PE详解之输入表(导出表)详解(PE详解09)
小甲鱼PE详解之输出表(导出表)详解(PE详解09) 当PE 文件被执行的时候,Windows 加载器将文件装入内存并将导入表(Export Table) 登记的动态链接库(一般是DLL 格式)文件一 ...
- 取PE文件的引入表和导出表
直接上代码(这里列出C++和Delphi的代码),Delphi代码中包含导入及导出文件和函数列表,PE结构可参阅资料,很多很详细,需要注意的是,本例中是映射到内存,不是通过PE装载器装入的,所以对于节 ...
- MySQL 复制表结构
200 ? "200px" : this.width)!important;} --> 介绍 有时候我们需要原封不动的复制一张表的表结构来生成一张新表,MYSQL提供了两种便 ...
- SQL复制表结构或表数据
需求: 软件开发过程中,一般会部署两个数据库:一个测试数据库提供给开发和测试过程使用:一个运维数据库提供上线使用.当需求变化需增加表时,会遇到数据库表结构或表数据同步的问题,这时就要复制表结构或表数据 ...
- ORCALE复制表结构
1.oracle 复制表结构 不要内容 create table 表1 as select * from 表2 where 1=2 2.oracle 复制表结构 要内容 create table 表1 ...
- mysql 复制表结构、表数据的方法
From: http://blog.163.com/yaoyingying681@126/blog/static/109463675201191173221759/ MySQL 添加列,修改列,删除列 ...
- mysql复制表结构及检查表、存储过程是否存在
mysql命令行复制表结构的方法: 1.只复制表结构到新表 CREATE TABLE 新表 SELECT * FROM 旧表 WHERE 1=2 或者 CREATE TABLE 新表 LIKE 旧表 ...
随机推荐
- Linux中read命令的用法—(6/30)
read命令是一个非常重要的bash命令,用于从键盘或者表中输入中文本,并且可以和用户进行交互:该命令可以一次读取多个变量的值,变量和输入的值都需要使用空格隔开.在read命令后面,如果没有指定变量名 ...
- MySQL-5.7 高阶语法及流程控制
1.标签语句 [begin_label:] BEGIN [statement_list] END [end_label] [begin_label:] LOOP statement_list END ...
- 添加一个vue全局守卫,主要用于用户登录时候验证
//注册一个全局守卫,作用是在路由跳转钱,对路由进行判断,防止未登录用户跳转到其他页面 router.beforeEach((to, from, next) => { let token = l ...
- Linux下的sed命令使用详解
sed是stream editor的简称,也就是流编辑器.它一次处理一行内容,处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”pattern space,接着用sed命令处理缓冲区中的内容, ...
- [nowcoder]再编号
链接:https://www.nowcoder.com/acm/contest/158/C 每变化一次,tot=tot*(n-1),且每两个数之差delta*=-1,直接根据这两个性质暴力循环1000 ...
- LeetCode——Number Complement
LeetCode--Number Complement Question Given a positive integer, output its complement number. The com ...
- sql报字段过大的错误解决方法
set global max_allowed_packet = 2*1024*1024*10
- CodeChef FORESTGA 二分
Forest Gathering Problem code: FORESTGA Tweet ALL SUBMISSIONS All submissions for this problem ...
- scala学习手记4 - Java基本类型对应的scala类
在Java中变量类型分为两大类:基本类型和引用类型.虽然在JDK1.5以后引入了自动装箱和自动拆箱机制,大大减少了我们在直接类型和引用类型之间的纠结,但仍有一些我们不得不考虑的问题.比如我在工作遇到的 ...
- scala学习手记2 - scala中的循环
先来看一段Java中的循环: for (int i = 1; i < 4; i++) { System.out.print(i + ","); } 毫无疑问,scala可以让 ...