赞
踩
- ---------- 禁止修改 ----------
- drop database if exists mydb cascade;
- ---------- 禁止修改 ----------
-
-
- ---------- begin ----------
- ---创建mydb数据库
- create database mydb;
-
- ---使用mydb数据库
- use mydb;
-
- ---创建表user
- create table usertab(
- id int,
- sex string,
- time string,
- education string,
- occupation string,
- income string,
- area string,
- desired_area string,
- city_countryside string
- )row format delimited fields terminated by ',';
-
-
-
-
- ---导入数据:/root/data.txt
- load data local inpath '/root/data.txt' into table usertab;
-
- --查询每一个用户从出生到2019-06-10的总天数
- select id,datediff(cast('2019-06-10' as date),cast(regexp_replace(time, '/', '-') as date)) from usertab;
-
-
-
-
- ---------- end ----------
- ---------- 禁止修改 ----------
- drop database if exists mydb cascade;
- ---------- 禁止修改 ----------
-
-
- ---------- begin ------
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。