`
liuxingguome
  • 浏览: 23528 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
文章分类
社区版块
存档分类
最新评论

mysql常用函数

 
阅读更多
日期格式化:
date_format(now(),'%Y-%m-%d %H:%i:%s')

添加外键
alter table locstock add foreign key locstock_ibfk2(stockid) references product(stockid)
locstock 为表名, locstock_ibfk2 为外键名 第一个括号里填写外键列名, product为表名,第二个括号里是写外键关联的列名
 
删除外键
alter table locstock drop foreign key locstock_ibfk2
update t_oa_wjmlxx t1 inner join t_oa_wjccxx t2  on t1.mlxxid=t2.parentid and t2.wjccxxid in ('2c90d8c35003b7eb015004187a0f0013') set t1.xgsj=now(), t1.xgr='admin'

select t.bh,
       t.clsj,
       t.dm,
       t.fjdz,
       t.isshpt,
       t.jlnf,
       t.lyzt,
       t.nr,
       t.sldw,
       t.title,
       date_format(t.tjsj, '%Y-%m-%d') as tjsj,
       t.tjzsf,
       t.twzxm,
       d.name,
       z.zdmc as ztmc,
       (select case
                 when t.lyzt = '00007' then
                  'green.jpg'
                 else
                  s.tblj
               end) as tblj
  from t_ygfw_message t
  left join t_ygfw_dept d
    on t.sldw = d.dm
  left join sjzd z
    on t.lyzt = z.zddm
  left join t_ygfw_sjdcsb s
    on (unix_timestamp(now()) - unix_timestamp(t.tjsj)) / (60 * 60 * 24) + 0.5 >=
       s.mintime
   and (unix_timestamp(now()) - unix_timestamp(t.tjsj)) / (60 * 60 * 24) + 0.5 <
       s.maxtime
 where 1 = 1
 order by t.tjsj desc, t.bh asc;

mysql查询行号:
rownum:=@rownum+1,

mysql设置查询超时时间:

[root@ ~]# mysql -h 192.168.0.* -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8174
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show global variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout | 28800 |
+---------------+-------+
1 row in set (0.00 sec)

mysql> set global wait_timeout=86400;
Query OK, 0 rows affected (0.00 sec)

mysql> show global variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout | 86400 |
+---------------+-------+
1 row in set (0.00 sec)

 

interactive_timeout :等待某个活动连接 关闭连接前等待的秒数

 

wait_timeout:等待某个非活动连接关闭连接前等待的秒数。

 

net_read_timeout:在中止读取之前等待来自连接的更多数据的秒数。

 

net_write_timeout:在中止写入之前等待块写入连接的秒数。

 

分享到:
评论

相关推荐

    MySQL常用函数大全

    基本上常用的都在这里了,如有遗漏还望指出。 MySQL常用函数大全

    MySQL常用函数.txt

    MySQL常用函数 MySQL常用函数

    mysql 常用函数

    mysql常用函数 ,供大家学习 工作之用

    MySQL常用函数

    包含了MySQL常用的所有函数及详解。IFNULL(expr1,expr2),FROM_UNIXTIME。

    MySQL常用函数的举例及例子

    MySQL函数举例常用函数的分类等,列举出常用函数的种类和用法,规范的举例,使您学习更轻松

    Mysql常用函数列表

    Mysql常用函数列表 CONCAT (string2 [,... ]) //连接字串 INSTR (string ,substring ) //返回substring首次在string中出现的位置,不存在返回0 …… 数学类 ABS (number2 ) //绝对值 …… 日期...

    MySql常用函数大全讲解

    MySql常用函数大全讲解,数学函数 字符串函数 日期和时间函数 条件判断函数 系统信息函数 加密函数 格式化函数

    Mysql常用函数

    Mysql常用函数

    MySQL常用函数.pdf

    MySQL常用函数.pdf

    mysql常用函数及概念

    此文档为mysql常用函数以及概念性问题包含优化函数的使用。

    mysql常用函数大全

    mysql常用函数大全,不用每次去网上查,快速便捷

    mysql常用函数汇总.chm

    Mysql的常用函数整体, 从网上收集的一些常用函数, 进行汇总整体成文档 MySQL控制流函数: CASE WHEN[test1] THEN [result1]...ELSE [default] END如果testN是真,则返回resultN,否则返回default CASE [test] WHEN...

    mysql常用函数汇总.pdf

    mysql常用函数汇总.pdf

    MySQL 常用函数的使用

    MySQL 常用函数1. 字符串函数a. 常用函数b. 导入数据c. 示例题目2. 日期函数a. 常用函数b. 示例题目3. 数字函数a. 常用函数b. 示例题目4. 高级函数a. CASE 表达式i. 语法ii. 示例题目b. IF 表达式i. 语法ii. 示例...

Global site tag (gtag.js) - Google Analytics