---
title: "mysql 是否存在表、字段、列"
author: "duan1823a"
date: "2011-03-22T16:00:03Z"
tags: ["MySQL", "SQL"]
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2011-03-22T16:00:03Z"
id: 970688
url: "https://duan1823a.iteye.com/blog/970688"
---

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

```