判断mysql表是否存在四种方法:
1. 通过information_schema
判断一个表是否存在
SELECT table_name FROM information_schema.TABLES WHERE table_name ='yourname';
指定数据库指定表是否存在
SELECT table_name FROM information_schema.TABLES WHERE table_schema='dbname' and table_name ='yourname';
2. show tables
SHOW TABLES LIKE 'table_mode'
3. 在建表时不确定表是否存在
--格式 CREATE TABLE IF NOT EXISTS [Table Definition]; --示例 CREATE TABLE IF NOT EXISTS student(id int unsigned not null primary key,name varchar(32) not null)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。