ITeye博客

mysql 是否存在表、字段、列

duan1823a · 2011-03-22 16:00 · 数据库 · SQL · MySQL · Markdown


# 查表是否存在
SELECT count(*) FROM information_schema.tables WHERE table_name = 'btoc_definition'

show columns from btoc_definition like 'status1'

describe btoc_definition DISPLAYNAME

# 是否存在列
SELECT count(*) FROM(
	select COLUMN_NAME from information_schema.COLUMNS 
		where TABLE_SCHEMA='b2c' 
		and TABLE_NAME='btoc_definition' 
		and COLUMN_NAME='name'
)

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。