成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

MySQL常用查詢Databases和Tables

數據庫 MySQL
本篇文章分享一下工作中常見的MySQL腳本,具體內容如下,我們一起來看。

分享一下工作中常見的mysql腳本,此次分享的內容如下:

  • Databases
  • tables

一、Databases and schemas

列出了 MySQL 實例上的用戶數據庫(模式):

select schema_name as database_name
from information_schema.schemata
where schema_name not in('mysql','information_schema',
'performance_schema','sys')
order by schema_name

說明:database_name - 數據庫(模式)名稱。

二、Tables

1. 列出 MySQL 數據庫中的表

下面的查詢列出了當前或提供的數據庫中的表。要列出所有用戶數據庫中的表

(1) 當前數據庫

select table_schema as database_name,
table_name
from information_schema.tables
where table_type = 'BASE TABLE'
and table_schema = database()
order by database_name, table_name;

說明:

  • table_schema - 數據庫(模式)名稱
  • table_name - 表名

(2) 指定數據庫

select table_schema as database_name,
table_name
from information_schema.tables
where table_type = 'BASE TABLE'
and table_schema = 'database_name' -- enter your database name here
order by database_name, table_name;

說明:

  • table_schema - 數據庫(模式)名稱
  • table_name - 表名

2. 列出 MySQL 中所有數據庫的表

下面的查詢列出了所有用戶數據庫中的所有表:

select table_schema as database_name,
table_name
from information_schema.tables
where table_type = 'BASE TABLE'
and table_schema not in ('information_schema','mysql',
'performance_schema','sys')
order by database_name, table_name;

說明:

  • table_schema - 數據庫(模式)名稱
  • table_name - 表名

3. 列出 MySQL 數據庫中的 MyISAM 表

select table_schema as database_name,
table_name
from information_schema.tables tab
where engine = 'MyISAM'
and table_type = 'BASE TABLE'
and table_schema not in ('information_schema', 'sys',
'performance_schema','mysql')
-- and table_schema = 'your database name'
order by table_schema,
table_name;

說明:

  • database_name - 數據庫(模式)名稱
  • table_name - 表名

4. 列出 MySQL 數據庫中的 InnoDB 表

select table_schema as database_name,
table_name
from information_schema.tables tab
where engine = 'InnoDB'
and table_type = 'BASE TABLE'
and table_schema not in ('information_schema', 'sys',
'performance_schema','mysql')
-- and table_schema = 'your database name'
order by table_schema,
table_name;

說明:

  • database_name - 數據庫(模式)名稱
  • table_name - 表名

5. 識別 MySQL 數據庫中的表存儲引擎(模式)

select table_schema as database_name,
table_name,
engine
from information_schema.tables
where table_type = 'BASE TABLE'
and table_schema not in ('information_schema','mysql',
'performance_schema','sys')
-- and table_schema = 'your database name'
order by table_schema,
table_name;

說明:

(1)table_schema - 數據庫(模式)名稱

(2)table_name - 表名

(3)engine- 表存儲引擎??赡艿闹担?/p>

  • CSV
  • InnoDB
  • 記憶
  • MyISAM
  • 檔案
  • 黑洞
  • MRG_MyISAM
  • 聯合的

6. 在 MySQL 數據庫中查找最近創建的表

select table_schema as database_name,
table_name,
create_time
from information_schema.tables
where create_time > adddate(current_date,INTERVAL -60 DAY)
and table_schema not in('information_schema', 'mysql',
'performance_schema','sys')
and table_type ='BASE TABLE'
-- and table_schema = 'your database name'
order by create_time desc,
table_schema;

MySQL 數據庫中最近 60 天內創建的所有表,按表的創建日期(降序)和數據庫名稱排序

說明:

  • database_name - 表所有者,模式名稱
  • table_name - 表名
  • create_time - 表的創建日期

7. 在 MySQL 數據庫中查找最近修改的表

select table_schema as database_name,
table_name,
update_time
from information_schema.tables tab
where update_time > (current_timestamp() - interval 30 day)
and table_type = 'BASE TABLE'
and table_schema not in ('information_schema', 'sys',
'performance_schema','mysql')
-- and table_schema = 'your database name'
order by update_time desc;

所有數據庫(模式)中最近 30 天內最后修改的所有表,按更新時間降序排列

說明:

  • database_name - 數據庫(模式)名稱
  • table_name - 表名
  • update_time - 表的最后更新時間(UPDATE、INSERT 或 DELETE 操作或 MVCC 的 COMMIT)
責任編輯:趙寧寧 來源: 今日頭條
相關推薦

2021-03-02 12:34:47

MySQL解鎖表鎖定表

2022-05-30 06:30:20

查詢MySQL數據庫

2018-12-24 18:12:41

SQL ServerMySQL數據庫

2018-03-29 19:45:47

數據庫MySQL查詢優化

2019-08-14 15:18:55

MySQLSQL數據庫

2019-03-25 19:13:37

MySQL常用工具數據庫

2018-10-12 16:45:10

MySQL查詢日志數據庫

2018-06-07 08:54:01

MySQL性能優化索引

2021-04-09 23:00:12

SQL數據庫Pandas

2010-11-25 10:21:20

MySql查詢時間段

2009-08-05 10:08:55

MySQL查詢優化調度鎖定

2011-03-03 16:10:04

Mysql數據庫備份還原

2021-01-28 23:26:55

MySQL

2017-09-01 21:00:05

MySQLSQL優化查詢方法

2021-07-05 09:24:06

MySQL SQL 語句數據庫

2009-06-16 10:36:00

Google Fusi應用實例

2010-05-27 16:12:10

MySQL索引

2013-05-17 10:43:32

2017-09-18 15:20:02

MySQL慢查詢日志配置

2010-11-25 13:05:26

MySQL列類型
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 欧美一区久久 | 日本爱爱| 精品三级在线观看 | 中文字幕一区二区三区乱码在线 | 欧美激情一区二区三区 | 中文字幕11页 | 蜜桃传媒一区二区 | 欧美在线a | 国产高潮好爽受不了了夜色 | 国产精品久久久久久久久久免费看 | av国产精品 | 久久久精彩视频 | 你懂的在线视频播放 | 国产精品久久国产精品久久 | 国产一区不卡 | 欧美性影院 | 国产成人精品一区二 | 国产成人免费视频 | 91精品国产美女在线观看 | a级片在线| 国产高清精品一区 | 人人人人干 | 91免费在线 | 欧美亚洲免费 | 欧美日韩国产在线观看 | 一区二区三区四区国产 | 美国一级毛片a | 精品日韩一区二区 | 国产精品久久亚洲 | 8x国产精品视频一区二区 | 欧美国产一区二区 | 91精品国产一区二区三区动漫 | 中文久久 | 99精品热视频 | 91在线精品一区二区 | 秋霞性生活| 男女羞羞视频在线观看 | 男人天堂视频在线观看 | 午夜av免费 | 久久丝袜| 国产亚洲精品精品国产亚洲综合 |