萌新入行-数据上传

来源:互联网 发布:ubuntu 安装到u盘 编辑:程序博客网 时间:2024/05/22 05:12

工作日志  2017.11.29

——————数据上传(信息共享平台)

1、将数据上传到临时数据库

临时库名: bmgx_n_temp

密码:*****

Orc140    normal

(1)创建表表名前加T_

名称:T_

表空间:HAS_DATA(自选)

注释:表名解释

列:根据表格的表头创建

(2)编辑kettle-spoon

         例:将Excel插入到数据库中

a、 创建新的转换

Excel输入:文件、工作表、字段

字段选择:获取字段、列映射

表输出:数据库链接、目标表

b、 应用

 

 

2、查询是否有数据重复或错误

注:orcale常用的查询命令:

         Select * from tables(表名);   //查询表tables的内容

         Truncate table tables(表名);//清除表内数据;但保留格式

         Select ID(列名)from tables  group by ID(列名)ID2(列名)having count(*)1 //查询表中重复的数据

Select * from tables(表名) a where a.id(列名)=’07552223’(重复的数据)//将在列ID中所有与07552223相同的数据排列出来

delete from tables where rowid in (select min(rowid)fromtables where id=’15252525’) group by username);  //删除table表中ID列数据为‘15252525’的重复项

delete from table where rowid in(select min(rowid)fromtable group by id..id2);  //删除表table中所有关于列(ID)的重复信息

 

 

3、将临时数据库的数据放入正式数据库

(1)打开新的数据库(正式数据库):

数据库名:bmgx_n_wys 密码:****

(2)新建表:

表名……

表空间:HAS_DATA

空闲:10

初始事物数:1

最大事务数:255

(3)列:具有固定内容

         IIDD、SJLY、SJLYBM……..ISSDEL共11个+复制临时数据库中的列

(4)主键:名称:PK_表名_IIDD    列:IIDD     允许:(√)

(5)索引:名称:IX_表名_IIDD     列:xm…..     存储:1.表空间:自选 2.空闲:10 3.下一个2M 4.初始/最终大小:2/255

(6)打开一个新的kttle-spoon;连接数据库     数据库名:bmgx_n_wys 密码:****

(7)新建转换

a) 表输入:名称:临时数据库表名;获取SQL查询语句

必加f_get_sfzhm18(zjhm)ZJHM

   f_get_qp(xm)as XMQP

   f_get_jp(XM)as XMJP

b) 字段选择:获取选择的字段、列映射

c) 表输出:名称:正式表名;目标表:正式表名;

4、发布数据

(1)   登录景德镇共享平台:10.137.185.34:90/sdp  用户名:admin  密码:****

(2)   引用表、创建功能、功能授权、创建菜单

 

附录:网络资源代码

--去重查询方法一:根据id

select * from sxe where id in(selectmin(id) from sxe group by username) order by id asc;
--去重查询方法二:根据rownum
select * from (select s.*,rownum rn from sxe s ) x where x.rn in (selectmin(rownum) from sxe group by username) order by id asc;
--去重查询方法三:根据rowid
select * from (select s.*,rowid rid from sxe s) x where x.rid in (selectmin(rowid) from sxe group by username) order by id asc;

select s.*,rowid from sxe s where rowidin (select min(rowid) from sxe group by username) order by id asc;


--去重删除方法一:根据ID
delete from sxe where id not in (select min(id) from sxe group by username);
--去重删除方法二:根据rownum
delete from (select s.*,rownum from sxe s) x where rownum not in (selectmin(rownum) from sxe group by username);
--去重删除方法三:根据rowid

delete from sxe where rowid not in (select min(rowid)from sxe group by username);

 

Disctinct关键词多列问题:

关于数据迁移,如何处理大数据量重复问题?针对Oracle

--按照table2的结构创建table1,并将table2的数据导入table1;

create table table1 selet * from table2;

--按照table2的结构创建table1,但不导入数据;

create table table1 select * from table2 where 1 = 2;

大数据迁移就是:

create table temp_table select * from table2 where id notin (select min(id) from table1 group by coln) order by coln asc;

drop table table2;

rename temp_table to table2;

关于数据库表结构编辑,针对Oracle:

增加列:

alter table table1 add column_name column_type;

修改列大小:

alter table table1 modify column_name new_column_type;

修改列名称:

alter table table1 rename column cln1 to cln2;

删除列:

alter table tabl1 drop column cln1;

阅读全文
0 0
原创粉丝点击