mysql种table schema_mysql中table schema的基本操作

我们通常对数据库进行的增删插检操作,是针对数据库中的文件。mysql数据库中还有一些表(是view,只能做select操作)记录了现有表的meta data,比如某个column的名字,它的定义是什么等等。

1. 列出test数据库中所有的表名,类型(普通表还是view)和使用的引擎

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指的是表的类型

2. 检查数据库'test'中的某一个表'd_ad'是否存在

select count(1) from information_schema.tables where table_schema = 'test' and table_name = 'd_ad';

3. 检查都一张表‘test.d_ad’的某一栏'ad_id'的类型

select column_type from information_schema.columns where TABLE_SCHEMA = 'test' and TABLE_NAME = 'd_ad' and COLUMN_NAME = 'ad_id';

解释: 对于某一个表中具体field的查询,需要使用表information_schema.columns

4. 更改某一栏的定义;

alter table test.d_ad modify column ad_id bigint(20) DEFAULT 0;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值