mysql 一些知识点

常用的实用sql语句:

1.example:   SELECT *,FROM_UNIXTIME(f_create_time/1000,'%Y-%m-%d %H:%i:%s') date from report.t_org_exam_num_day  ORDER BY date desc

   FROM_UNIXTIME()把毫秒级别的时间转换为年月日,时分秒格式的

2.查询mysql 建表时间:SELECT CREATE_TIME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='db_campus(库名)' AND TABLE_NAME='tb_ilovi_device(表名)';

MySQL 查看表结构简单命令。

一、简单描述表结构,字段类型desc tabl_name;
显示表结构,字段类型,主键,是否为空等属性,但不显示外键。
二、查询表中列的注释信息
select * from information_schema.columns where table_schema = 'db' #表所在数据库
and table_name = 'tablename' ; #你要查的表
三、只查询列名和注释
select column_name,
column_comment from information_schema.columns where table_schema ='db' and
table_name = 'tablename' ;
四、#查看表的注释
select table_name,table_comment from information_schema.tables where table_schema = 'db' and table_name ='tablename'

查看MYSQL数据库中所有用户
mysql> SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

查看数据库中具体某个用户的权限
mysql> show grants for 'cactiuser'@'%';   

mysql> select * from mysql.user where user='cactiuser' \G   

查看user表结构 需要具体的项可结合表结构来查询
mysql> desc mysql.user;

Mysql数据库自带四个数据库的解析 

参考网址见:https://www.cnblogs.com/bobi-PHP-blog/p/7508660.html

猜你喜欢

转载自www.cnblogs.com/lipengsheng-javaweb/p/11419209.html