i漂泊

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3535|回复: 0

mysql判断字段是否存在的方法

[复制链接]
TA的礼物信息
  • 收到:0
  • 送出:2
发表于 2016-5-10 09:03:57 | 显示全部楼层 |阅读模式
mysql判断字段是否存在的方法有很多,如使用desc命令、show columns 命令、describe 命令等等,感兴趣的朋友可以参考下

1. desc 命令
格式:
  1. desc tablename columnname
复制代码


例子:
  1. desc `table` `mid`
  2. desc `table` '%abc%'
复制代码
2. show columns 命令
格式:
  1. show columns from tablename like columnname
复制代码

例子:
  1. show columns from `table` like 'mid'
  2. show columns from `table` like '%abc%'
复制代码


3. describe 命令
格式:
  1. describe tablename columnname
复制代码

describe 相當于 show columns from
例子:
  1. describe `table` `mid`

  2. describe `table` '%abc%'
复制代码


回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

QQ|小黑屋|手机版|IPiaoBo Inc. ( 渝ICP备17002826号 )

GMT+8, 2025-5-6 22:07 , Processed in 0.089513 second(s), 47 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表