日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
MySQL常用查詢Databases和Tables

分享一下工作中常見(jiàn)的mysql腳本,此次分享的內(nèi)容如下:

在網(wǎng)站制作、成都做網(wǎng)站中從網(wǎng)站色彩、結(jié)構(gòu)布局、欄目設(shè)置、關(guān)鍵詞群組等細(xì)微處著手,突出企業(yè)的產(chǎn)品/服務(wù)/品牌,幫助企業(yè)鎖定精準(zhǔn)用戶,提高在線咨詢和轉(zhuǎn)化,使成都網(wǎng)站營(yíng)銷(xiāo)成為有效果、有回報(bào)的無(wú)錫營(yíng)銷(xiāo)推廣。創(chuàng)新互聯(lián)專業(yè)成都網(wǎng)站建設(shè)10余年了,客戶滿意度97.8%,歡迎成都創(chuàng)新互聯(lián)客戶聯(lián)系。

  • Databases
  • tables

一、Databases and schemas

列出了 MySQL 實(shí)例上的用戶數(shù)據(jù)庫(kù)(模式):

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

說(shuō)明:database_name - 數(shù)據(jù)庫(kù)(模式)名稱。

二、Tables

1. 列出 MySQL 數(shù)據(jù)庫(kù)中的表

下面的查詢列出了當(dāng)前或提供的數(shù)據(jù)庫(kù)中的表。要列出所有用戶數(shù)據(jù)庫(kù)中的表

(1) 當(dāng)前數(shù)據(jù)庫(kù)

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;

說(shuō)明:

  • table_schema - 數(shù)據(jù)庫(kù)(模式)名稱
  • table_name - 表名

(2) 指定數(shù)據(jù)庫(kù)

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;

說(shuō)明:

  • table_schema - 數(shù)據(jù)庫(kù)(模式)名稱
  • table_name - 表名

2. 列出 MySQL 中所有數(shù)據(jù)庫(kù)的表

下面的查詢列出了所有用戶數(shù)據(jù)庫(kù)中的所有表:

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;

說(shuō)明:

  • table_schema - 數(shù)據(jù)庫(kù)(模式)名稱
  • table_name - 表名

3. 列出 MySQL 數(shù)據(jù)庫(kù)中的 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;

說(shuō)明:

  • database_name - 數(shù)據(jù)庫(kù)(模式)名稱
  • table_name - 表名

4. 列出 MySQL 數(shù)據(jù)庫(kù)中的 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;

說(shuō)明:

  • database_name - 數(shù)據(jù)庫(kù)(模式)名稱
  • table_name - 表名

5. 識(shí)別 MySQL 數(shù)據(jù)庫(kù)中的表存儲(chǔ)引擎(模式)

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;

說(shuō)明:

(1)table_schema - 數(shù)據(jù)庫(kù)(模式)名稱

(2)table_name - 表名

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

  • CSV
  • InnoDB
  • 記憶
  • MyISAM
  • 檔案
  • 黑洞
  • MRG_MyISAM
  • 聯(lián)合的

6. 在 MySQL 數(shù)據(jù)庫(kù)中查找最近創(chuàng)建的表

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 數(shù)據(jù)庫(kù)中最近 60 天內(nèi)創(chuàng)建的所有表,按表的創(chuàng)建日期(降序)和數(shù)據(jù)庫(kù)名稱排序

說(shuō)明:

  • database_name - 表所有者,模式名稱
  • table_name - 表名
  • create_time - 表的創(chuàng)建日期

7. 在 MySQL 數(shù)據(jù)庫(kù)中查找最近修改的表

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;

所有數(shù)據(jù)庫(kù)(模式)中最近 30 天內(nèi)最后修改的所有表,按更新時(shí)間降序排列

說(shuō)明:

  • database_name - 數(shù)據(jù)庫(kù)(模式)名稱
  • table_name - 表名
  • update_time - 表的最后更新時(shí)間(UPDATE、INSERT 或 DELETE 操作或 MVCC 的 COMMIT)

當(dāng)前題目:MySQL常用查詢Databases和Tables
網(wǎng)頁(yè)URL:http://m.5511xx.com/article/codjoii.html