判断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)
总结
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您喜欢交流学习经验,点击链接加入交流1群:1065694478(已满)交流2群:163560250