MySQL常用知识库

  经过一段时间,我们公司从SqlServer数据库又迈入了MySQL,项目也做了整体的调整。记录一下MySQL中用到的一些函数,语句等<---以后会持续更新--->

     1, IFNULL(expr1,expr2); 类似oracle中的nvl(expr1,expr2)方法;用法:若expr1 为null,则返回expr2;若不为null ,返回expr1本身。

  2,unix_timestamp(expr);  用法:将字符型的时间,转成unix时间戳。可以用于比较时间。

  3,SELECT COUNT(*) TABLES, table_schema FROM information_schema.TABLES   WHERE table_schema = '表所在的数据库' GROUP BY table_schema;   查看数据库中有多少张表

  4,show tables; 查看当前数据库中所有表名;

  5,查询数据库中 某表的所有字段

select * from information_schema.`COLUMNS`
where table_schema = 'health_online' #表所在数据库
and table_name in ('user_info','bp_record') ; #你要查的表

Linux环境下:

  1,连接mysql:mysql -uroot -p

       U0-z(6sLdrTZRXKg

  2,show databases; 展示所有数据库

  3,show tables; 展示所有表


                                                       记录点点点滴滴,虽然微不足道。

原文地址:https://www.cnblogs.com/chenjle/p/7262048.html