mysql 是否存在表、字段、列

# 查表是否存在
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'
)


你可能感兴趣的:(sql,mysql)