1.rz 彈出對(duì)話框 CRT軟件才有的
2.window--》linux
? winscp 綠色
3. scp
將文件/文件夾 從A機(jī)器傳到B機(jī)器
hadoop000:
scp jepson.log? ? ? 192.168.137.141:/tmp
scp xxx.log? ? root@hadoop001:/tmp
scp -r /ruozedata root@hadoop001:/tmp
升級(jí)版:
scp root@hadoop001:/tmp/jepson.log? /tmp
4.ssh? ?
ssh hadoop001? ? ? ? ? ? ? ? ? 登錄其他機(jī)器
ssh root@hadoop001? ? ? ? ? ? 登錄其他機(jī)器
ssh hadoop001? date? ? ? 將命令在目標(biāo)機(jī)器執(zhí)行侣集,結(jié)果返回
5.ssh-keygen 做多臺(tái)機(jī)器間? 互相信任?
http://blog.itpub.net/30089851/viewspace-1992210/
文件夾: ~/.ssh
生成:
rm -rf ~/.ssh
[root@hadoop000 ~]# ssh-keygen
[root@hadoop001 ~]# ssh-keygen
選擇第一臺(tái)作為先完善的機(jī)器
[root@hadoop000 .ssh]# cat id_rsa.pub >> authorized_keys
其他機(jī)器將id_rsa.pub發(fā)送給第一臺(tái)
[root@hadoop001 .ssh]# scp id_rsa.pub? 192.168.137.251:/root/.ssh/id_rsa.pub.hadoop001
[root@hadoop002 .ssh]# scp id_rsa.pub? 192.168.137.251:/root/.ssh/id_rsa.pub.hadoop001
[root@hadoop003 .ssh]# scp id_rsa.pub? 192.168.137.251:/root/.ssh/id_rsa.pub.hadoop001
[root@hadoop004 .ssh]# scp id_rsa.pub? 192.168.137.251:/root/.ssh/id_rsa.pub.hadoop001
將其他機(jī)器的id_rsa.pub追加到authorized_keys
[root@hadoop000 .ssh]# cat id_rsa.pub.hadoop001 >> authorized_keys
[root@hadoop000 .ssh]# cat id_rsa.pub.hadoop002 >> authorized_keys
[root@hadoop000 .ssh]# cat id_rsa.pub.hadoop003 >> authorized_keys
[root@hadoop000 .ssh]# cat id_rsa.pub.hadoop004 >> authorized_keys
然后將該authorized_keys分發(fā)
[root@hadoop000 .ssh]# scp authorized_keys 192.168.137.141:/root/.ssh/
[root@hadoop000 .ssh]# scp authorized_keys 192.168.137.142:/root/.ssh/
[root@hadoop000 .ssh]# scp authorized_keys 192.168.137.143:/root/.ssh/
[root@hadoop000 .ssh]# scp authorized_keys 192.168.137.144:/root/.ssh/
每臺(tái)機(jī)器第一次要做: yes --> known_hosts
[root@hadoop000 .ssh]# ssh hadoop000 date
[root@hadoop000 .ssh]# ssh hadoop001 date
[root@hadoop000 .ssh]# ssh hadoop002 date
[root@hadoop000 .ssh]# ssh hadoop003 date
[root@hadoop000 .ssh]# ssh hadoop004 date
升級(jí)版(作業(yè)): A機(jī)器scp一個(gè)文件到B機(jī)器 無(wú)需密碼
A --> B
---------------------------------------------------------------
SQL常規(guī)使用二:
1.復(fù)習(xí)
? 字段類(lèi)型
? create table? 模板
? insert
? update
? delete
? select
? where
2.見(jiàn)sql語(yǔ)法.sql
--表 table
create table ruozedata(
id int AUTO_INCREMENT primary key,
name varchar(100),
age int,
createtime timestamp DEFAULT CURRENT_TIMESTAMP,
creuser varchar(100),
updatetime timestamp? DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
updateuser varchar(100)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
drop table ruozedata;
insert into? ruozedata(id,name,age) values(1,'jepson',16);
insert into? ruozedata(id,name,age) values(2,'LY',18);
insert into? ruozedata(id,name,age) values(3,'ZX',19);
insert into? ruozedata(id,name,age) values(4,'ZX1',119);
insert into? ruozedata(name,age) values('jepson',16);
insert into? ruozedata(name,age) values('LY',18);
insert into? ruozedata(name,age) values('ZX',19);
insert into? ruozedata(name,age) values('ZX1',119);
insert into? ruozedata(name,age) values('甘偉',119);
insert into? ruozedata
values(5,'ZX1',119,'2017-10-10 00:00:00','xxx','2017-12-10 00:00:00','xxx1');
update ruozedata set age=22 where name='jepson';
update ruozedata set age=22 ;
delete from ruozedata where name='jepson';
select * from ruozedata where name='ly';
select id,name from ruozedata;
create table test select id,name from ruozedata;
create table test1 select id,name from ruozedata where 1<>1;
alter table ruozedata add address varchar(512);
alter table ruozedata drop address ;
alter table ruozedata add address varchar(512) after age;
#條件查詢(xún)
select * from? ruozedata;
select * from? ruozedata where name='jepson';
select * from? ruozedata where name='jepson' and id=999;?
select * from? ruozedata where name='jepson' or id=3;
select * from? ruozedata where name='jepson' and id=999 and (name='jepson' or id=3);
#數(shù)據(jù)倉(cāng)庫(kù) 事實(shí)表 維表
create table emp (
? ? empno numeric(4) not null,
? ? ename varchar(10),
? ? job varchar(9),
? ? mgr numeric(4),
? ? hiredate datetime,
? ? sal numeric(7, 2),
? ? comm numeric(7, 2),
? ? deptno numeric(2)
);
create table dept (
? ? deptno numeric(2),
? ? dname varchar(14),
? ? loc varchar(13)
);
create table salgrade (
? ? grade numeric,
? ? losal numeric,
? ? hisal numeric
);
insert into dept values (10, 'ACCOUNTING', 'NEW YORK');
insert into dept values (20, 'RESEARCH', 'DALLAS');
insert into dept values (30, 'SALES', 'CHICAGO');
insert into dept values (40, 'OPERATIONS', 'BOSTON');
insert into salgrade values (1, 700, 1200);
insert into salgrade values (2, 1201, 1400);
insert into salgrade values (3, 1401, 2000);
insert into salgrade values (4, 2001, 3000);
insert into salgrade values (5, 3001, 9999);
insert into emp values (7369, 'SMITH', 'CLERK', 7902, '1980-12-17', 800, null, 20);
insert into emp values (7499, 'ALLEN', 'SALESMAN', 7698, '1981-02-20', 1600, 300, 30);
insert into emp values (7521, 'WARD', 'SALESMAN', 7698, '1981-02-22', 1250, 500, 30);
insert into emp values (7566, 'JONES', 'MANAGER', 7839, '1981-04-02', 2975, null, 20);
insert into emp values (7654, 'MARTIN', 'SALESMAN', 7698, '1981-09-28', 1250, 1400, 30);
insert into emp values (7698, 'BLAKE', 'MANAGER', 7839, '1981-05-01', 2850, null, 30);
insert into emp values (7782, 'CLARK', 'MANAGER', 7839, '1981-06-09', 2450, null, 10);
insert into emp values (7788, 'SCOTT', 'ANALYST', 7566, '1982-12-09', 3000, null, 20);
insert into emp values (7839, 'KING', 'PRESIDENT', null, '1981-11-17', 5000, null, 10);
insert into emp values (7844, 'TURNER', 'SALESMAN', 7698, '1981-09-08', 1500, 0, 30);
insert into emp values (7876, 'ADAMS', 'CLERK', 7788, '1983-01-12', 1100, null, 20);
insert into emp values (7900, 'JAMES', 'CLERK', 7698, '1981-12-03', 950, null, 30);
insert into emp values (7902, 'FORD', 'ANALYST', 7566, '1981-12-03', 3000, null, 20);
insert into emp values (7934, 'MILLER', 'CLERK', 7782, '1982-01-23', 1300, null, 10);
select * from emp where sal>3000;
select * from emp where sal<>5000;
#模糊查詢(xún) like
select * from emp where ename like '%S%';
select * from emp where ename like 'S%';
select * from emp where ename like '%S';
select * from emp where ename like '_O%';?
#排序
select * from emp order by? sal ;
select * from emp order by? sal asc ;
select * from emp order by? sal desc ;
#限制多少行
select * from emp limit? 3;
select * from emp order by? sal desc limit? 3;
#聚合
#count() sum()
#1.各個(gè)部門(mén)的薪水和
select deptno,sum(sal) from? emp group by deptno
select deptno,count(ename)
from? emp group by deptno
#2.group by字段 必須 出現(xiàn)在select字段后面? 各個(gè)部門(mén)的各個(gè)崗位的薪水和
select deptno,job,? sum(sal) from? emp group by deptno ,job
#3.having? ? 薪水和>5000的各個(gè)部門(mén)的各個(gè)崗位
select deptno,job,? sum(sal)
from? emp
group by deptno ,job
having? sum(sal)>5000
#4.常用組合where? order? limit
select deptno,job,? sum(sal) as sum_sal
from? emp
where job='SALESMAN'
group by deptno ,job
having? sum(sal)>5000
order by sum(sal) desc
limit 1
# as 別名
join 字段键俱、表名 加
not join 字段 加
#------------------join------------------------------
#left join,rigth join,inner join,join
#left join
create table testa(aid int,aname varchar(40));
create table testb(bid int,bname varchar(40),age int);
insert into testa values(1,'xiaoming');
insert into testa values(2,'LY');
insert into testa values(3,'KUN');
insert into testa values(4,'ZIDONG');
insert into testa values(5,'HB');
insert into testb values(1,'xiaoming',10);
insert into testb values(2,'LY',100);
insert into testb values(3,'KUN',200);
insert into testb values(4,'ZIDONG',110);
insert into testb values(6,'niu',120);
insert into testb values(7,'meng',130);
insert into testb values(8,'mi',170);
# left join
select
a.aid,a.aname,
b.bid,b.bname,b.age
from testa as a
left join testb as b on a.aid=b.bid
left join testc as c on b.aid=c.bid
A <---B
aid aname ? bid ? bname age
1 xiaoming 1 xiaoming 10
2 LY ? ? ? ? 2 LY ? ? ? ? 100
3 KUN ? ? ? ? 3 KUN ? ? ? ? 200
4 ZIDONG ? ? 4 ZIDONG ? ? 110
5 HB
# a left join b? a全,b表去匹配a表世分,匹配不到的 null
# right join
select
a.aid,a.aname,
b.bid,b.bname,b.age
from testa as a
right join testb as b on a.aid=b.bid
1 xiaoming 1 xiaoming 10
2 LY ? ? ? ? 2 LY ? ? ? ? 100
3 KUN ? ? ? ? 3 KUN ? ? ? ? 200
4 ZIDONG ? ? 4 ZIDONG ? ? 110
? ? ? ? 6 niu ? ? ? ? 120
? ? ? ? 7 meng ? ? 130
? ? ? ? 8 mi ? ? ? ? 170
A ----> B? ? ? ?
select
a.aid,a.aname,
b.bid,b.bname,b.age
from testa as a
inner join testb as b on a.aid=b.bid
1 xiaoming 1 xiaoming 10
2 LY ? ? ? ? 2 LY ? ? ? ? 100
3 KUN ? ? ? ? 3 KUN ? ? ? ? 200
4 ZIDONG ? ? 4 ZIDONG ? ? 110
select
a.aid,a.aname,
b.bid,b.bname,b.age
from testa as a
join testb as b on a.aid=b.bid
1 xiaoming 1 xiaoming 10
2 LY ? ? ? ? 2 LY ? ? ? ? 100
3 KUN ? ? ? ? 3 KUN ? ? ? ? 200
4 ZIDONG ? ? 4 ZIDONG ? ? 110
# testa
select '2018-05-12' as month,aid,aname from testa
union
select '2018-05-11' as month,aid,aname? from testa
2018-05 1 xiaoming
2018-05 2 LY
2018-05 3 KUN
2018-05 4 ZIDONG
2018-05 5 HB
2018-04 1 xiaoming
2018-04 2 LY
2018-04 3 KUN
2018-04 4 ZIDONG
2018-04 5 HB
create table testc(cid int,cretime timestamp);
insert into testc values(1,'2018-05-12 08:08:00');
insert into testc values(1,'2018-05-11 08:08:00');
insert into testc values(1,'2018-05-10 08:08:00');
insert into testc values(2,'2018-05-12 09:08:00');
insert into testc values(2,'2018-05-11 09:08:00');
insert into testc values(2,'2018-05-10 09:08:00');
insert into testc values(3,'2018-05-12 09:08:00');
insert into testc values(4,'2018-05-11 09:08:00');
#沒(méi)出勤人的ID和名稱(chēng)? 字表
select
a.day,a.aid,a.aname,
c.cid,c.cretime
from
(select '2018-05-12' as day,aid,aname from testa
union
select '2018-05-11' as day,aid,aname? from testa)? a
left join testc as c
on a.day=DATE_FORMAT(c.cretime, '%Y-%m-%d')
and a.aid=c.cid
where c.cid is not null;
# union? , union all
select? aid from testa
union
select? bid from testb
select? aid from testa
union all
select? bid from testb