有时候需要对一个特定的含有小数点的数字保留指定位数,比如"123.123600". 在数据库中以函数的形式实现如下: USE [数据库名称] GO /****** Object: UserDefinedFunction [dbo].[AvgLimit] Script Date: 2016/12/29 11:30:44 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ,),@numlimit int) ) As Begin
方式一: double f = 3.1516; BigDecimal b = new BigDecimal(f); , BigDecimal.ROUND_HALF_UP).doubleValue(); 输出结果f1为 3.15: 源码解读: public BigDecimal setScale(int newScale, int roundingMode) //int newScale 为小数点后保留的位数, int roundingMode 为变量进行取舍的方式: BigDecimal.ROU
2.看当前所有数据库:show databases; 3.进入mysql数据库:use mysql; 4.查看mysql数据库中所有的表:show tables; 5.查看user表中的数据:5以下版本使用select Host, User,Password from user;5及5以上版本使用mysql> select Host,User,authentication_string from user; 6.修改user表中的Host:update user set Host='%