mysql126_2020-12-06 mysql

P46-P51

数学函数

1.round 四舍五入

select round(1.45) //1

select round(1.55) //2

select round(1.45678, 2) //1.46,表示保留两位小数

2.ceil 向上取整 floor向下取整

select ceil(1.0001) //2

select ceil(-1.0001) //-1

3 truncate 截断

select truncate(1.6666,1) //1.6

// 1表示小数点后保留几位数字

4 mod取余

select mod(10,3) // 1

select mod(-10,3) // -1

select mod(10,-3) // 1

// 取余结果跟第一个数的符号相同

日期函数

1.now() 获取当前日期+时间

select now() // 2020-12-6 22:27:30

curdate() 获取当前系统日期,不包括时间

select curdate() // 2020-12-6

curtime() 获取当前系统时间,不包括日期

select curdate() // 22:27:30

4.获取指定的部分,年、月、日、时、分、秒。

select year(now()) as 年// 2020 这里必须往里传个date类型

select year('1998-1-8') // 1998

select month(now()) as 月// 12

select monthname(now())// December

str_to_date 将字符串通过指定的格式转换成日期

35c042ee85fa

image.png

select * from table where date = STR_TO_DATE('1-8 1998', '%c-%d %Y');

6 date_format 将日期转换成指定格式输出

select DATE_FORMAT(NOW(), '%Y年%m月%d日'); //2020年12月06日

其他函数

select version(); // 当前mysql的版本

select database(); // 当前数据库

select USER(); // 当前用户

2023-06-06 18:10:33,041 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7 2023-06-06 18:10:33,075 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead. 2023-06-06 18:10:33,218 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset. 2023-06-06 18:10:33,218 INFO tool.CodeGenTool: Beginning code generation Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. 2023-06-06 18:10:33,782 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `user_log` AS t LIMIT 1 2023-06-06 18:10:33,825 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `user_log` AS t LIMIT 1 2023-06-06 18:10:33,834 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /opt/module/hadoop-3.1.4 注: /tmp/sqoop-root/compile/5f4cfb16d119de74d33f1a0d776d5ae0/user_log.java使用或覆盖了已过时的 API。 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。 2023-06-06 18:10:35,111 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/5f4cfb16d119de74d33f1a0d776d5ae0/user_log.jar 2023-06-06 18:10:35,125 WARN manager.MySQLManager: It looks like you are importing from mysql. 2023-06-06 18:10:35,126 WARN manager.MySQLManager: This transfer can be faster! Use the --direct 2023-06-06 18:10:35,126 WARN manager.MySQLManager: option to exercise a MySQL-specific fast path. 2023-06-06 18:10:35,126 INFO manager.MySQLManager: Setting zero DATETIME behavior to convertToNull (mysql) 2023-06-06 18:10:35,130 ERROR tool.ImportTool: Import failed: No primary key could be found for table user_log. Please specify one with --split-by or perform a sequential import with '-m 1'.
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值