MYSQL 常用sql命令

grant all privileges on learn.*  to  'learn'@'%'  identified by 'learn'  with grant option;

update user set password=password("fk_dev") where user="fk_dev";

flush privileges;

grant all privileges on loan.* to loan_xs@"%" identified by "root" ;

/*远程数据库链接*/

flush privileges;

clean deploy -Dmaven.test.skip=true
/*调整自增主键开始大小*/
alter table users AUTO_INCREMENT=10000;
/*start transaction;*/

/*rollback;
commit;*/


truncate table  LB_T_CREDIT_AUDIT_INFO ; 

select table_name from information_schema.tables where table_schema='PTDEV';

select now() as 当前日期时间;

select LAST_INSERT_ID() as id;

select @@IDENTITY;

SHOW TABLE STATUS;

like concat('%',#{REASON},'%')

select seq_leave_demo_info.nextval as id from dual

select cast(11 as unsigned int) select cast(11 as decimal(10,2))

select auto_increment as id from information_schema.tables where  table_name='sys_resource'

to_char(sysdate,'yyyy-mm-dd')-->date_format(sysdate(),'%Y-%m-%d');
to_date(sysdate,'yyyy-mm-dd')-->STR_TO_DATE(sysdate(),'%Y-%m-%d');


to_char(sysdate,'yyyy-mm-dd')-->date_format(sysdate(),'%Y-%m-%d');
to_date(sysdate,'yyyy-mm-dd')-->STR_TO_DATE(sysdate(),'%Y-%m-%d');
to_date()-str_to_date('2012-05-01 23:59:59','%Y-%m-%d %T')

str_to_date(#{startTime},'%Y-%m-%d %T')

to_char()-date_format(date,'%Y-%m-%d')

%Y:代表4位的年份
%y:代表2为的年份
 
%m:代表月, 格式为(01……12)  
%c:代表月, 格式为(1……12)
 
%d:代表月份中的天数,格式为(00……31)  
%e:代表月份中的天数, 格式为(0……31) 
 
%H:代表小时,格式为(00……23)
%k:代表 小时,格式为(0……23)
%h: 代表小时,格式为(01……12)
%I: 代表小时,格式为(01……12)
%l :代表小时,格式为(1……12)
  
%i: 代表分钟, 格式为(00……59)

%r:代表 时间,格式为12 小时(hh:mm:ss [AP]M)
%T:代表 时间,格式为24 小时(hh:mm:ss)

%S:代表 秒,格式为(00……59)
%s:代表 秒,格式为(00……59)

ALTER TABLE `t_hr`
MODIFY COLUMN `remark`  varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注' AFTER `fullpath`;

SELECT *  from  表名 where `字段名` REGEXP '[a-z]+'
查询出的就是这个字段里包含字母的数据了

/* 比如将123转换为char类型 */
SELECT CAST(123 AS CHAR); 
/* 或者使用concat方法 */
SELECT CONCAT(123,'');


SELECT
column_name AS '列名',
data_type   AS '数据类型',
character_maximum_length  AS '字符长度',
numeric_precision AS '数字长度',
numeric_scale AS '小数位数',
is_nullable AS '是否允许非空',
CASE WHEN extra = 'auto_increment'
THEN 1 ELSE 0 END AS '是否自增',
column_default  AS  '默认值',
column_comment  AS  '备注'
FROM
Information_schema.columns
WHERE
table_Name='JBPM4_TASK';

发布了166 篇原创文章 · 获赞 60 · 访问量 36万+

猜你喜欢

转载自blog.csdn.net/chen978616649/article/details/89509066