坐标帝都,寻坑一个
create table if not exists dept ( deptno int, dname string, loc int ) row format delimited fields terminated by '\t'; create table if not exists emp (empno int, ename string, job string, mgr int, hiredate string, sal double, comm double, deptno int ) row format delimited fields terminated by '\t'; create table if not exists location ( loc int, loc_name string ) row format delimited fields terminated by '\t'; create table if not exists student ( id int, name string ) row format delimited fields terminated by '\t';
load data local inpath '/opt/datas/dept.txt' into table dept; load data local inpath '/opt/datas/emp.txt' into table emp; load data local inpath '/opt/datas/location.txt' into table location; load data local inpath '/opt/datas/student.txt' into table student;
-- 全表查询select * from emp; -- 指定列查询select empno, ename from emp;
1). SQL语言大小写不敏感
2). SQL可以写在一行或多行
3). 关键字不能被缩写,也不能分行
4). 各子句一般分行写
5). 使用缩进提高语句的可读性
-- 重命名一个列 -- 便于计算 -- 紧跟列名,也可以在列名和别名之间加入关键字 asselect ename name, deptno dn from emp;