前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SQL 精编(3)

SQL 精编(3)

作者头像
franket
发布2021-10-19 19:42:15
4490
发布2021-10-19 19:42:15
举报
文章被收录于专栏:技术杂记

show

代码语言:javascript
复制
show charset;
show character set;
show char set;
show character set like '%utf8%';
show collation like "%utf8%";
SHOW TABLE STATUS FROM `xxx_qa` LIKE 'abc'\G
show table status like 'conversations'\G
SHOW CREATE TABLE `xxxx_qa`.`abc`\G
SHOW INDEX FROM `xxxx_qa`.`abc`\G
show variables like "%format%";
show databases;
show tables;
show CREATE DATABASE `xxx_qa`
show grants for 'care'@'192.168.1.%';

index

代码语言:javascript
复制
create index profiles_on_user_id on  profiles(user_id);
create index conversations_on_user_id on conversations (user_id);

grant

代码语言:javascript
复制
grant create, CREATE TEMPORARY tables , CREATE VIEW , index , REFERENCES , drop , select , insert , update , delete , lock tables ,show view on xxx.* to 'xxx'@'192.168.1.%' identified by 'xxx';
grant alter on xxx.* to 'xxx'@'192.168.1.%';
GRANT RELOAD, SUPER, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'bkuser'@'localhost' IDENTIFIED BY 'xxx';
flush privileges;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE VIEW, SHOW VIEW ON `xxxxxx`.* TO 'xxxxx'@'192.168.1.%'  identified by 'xxxxxx';

select

代码语言:javascript
复制
select user();
select databases();
select version();
select * from information_schema.processlist where Command="sleep" and Time>86400;

desc

代码语言:javascript
复制
desc mysql.user
desc mysql.db

一些函数

时间相关函数

代码语言:javascript
复制
mysql> select date_sub(now(),interval 30 day);
+---------------------------------+
| date_sub(now(),interval 30 day) |
+---------------------------------+
| 2016-04-17 20:31:42             |
+---------------------------------+
1 row in set (0.00 sec)

mysql> select unix_timestamp(date_sub(now(),interval 30 day));
+-------------------------------------------------+
| unix_timestamp(date_sub(now(),interval 30 day)) |
+-------------------------------------------------+
|                                      1460896325 |
+-------------------------------------------------+
1 row in set (0.00 sec)

mysql> select to_days(date_sub(now(),interval 30 day));
+------------------------------------------+
| to_days(date_sub(now(),interval 30 day)) |
+------------------------------------------+
|                                   736436 |
+------------------------------------------+
1 row in set (0.00 sec)

mysql> select to_days(now());
+----------------+
| to_days(now()) |
+----------------+
|         736466 |
+----------------+
1 row in set (0.00 sec)

mysql> 

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • show
  • index
  • grant
  • select
  • desc
  • 一些函数
    • 时间相关函数
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档