上一片中介紹了安裝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