mysql數據庫中有一些表(是view,只能做select操作)記錄了現有表的meta data,比如某個column的名字,它的定義是什么等等。
select table_name, table_type, engine
FROM information_schema.tables
WHERE table_schema = ‘test’
ORDER BY table_name DESC;
解釋: 對表的meta data的查詢需要使用information_schema.tables, table_schema是數據庫的名稱,table_name是具體的表名,table_type指的是表的類型
mysql切換schema,select count(1) from information_schema.tables where table_schema = ‘test’ and table_name = ‘hello_world’;
select column_type from information_schema.columns where TABLE_SCHEMA = ‘test’ and TABLE_NAME = ‘hello_world’ and COLUMN_NAME = ‘a’;
解釋: 對于某一個表中具體field的查詢,需要使用表information_schema.columns
alter table test.hello_world modify column a bigint(20) DEFAULT 0;
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态