如果表存在,则放下表,然后创建它;如果不存在,则创建它 [英] If table exists drop table then create it, if it does not exist just create it
本文介绍了如果表存在,则放下表,然后创建它;如果不存在,则创建它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我很沮丧,我不知道该怎么做.
I'm stumped, I don't know how to go about doing this.
基本上我只想创建一个表,但是如果它存在,则需要删除并重新创建它,而不是将其截断,但是如果不存在,则可以创建它.
Basically I just want to create a table, but if it exists it needs to be dropped and re-created, not truncated, but if it doesn't exist just create it.
任何人都可以提供帮助吗?
Would anyone be able to help?
谢谢, 乔治
推荐答案
只需将DROP TABLE IF EXISTS `tablename`;
放在您的CREATE TABLE
语句之前.
Just put DROP TABLE IF EXISTS `tablename`;
before your CREATE TABLE
statement.
该语句将删除该表(如果存在),但如果不存在则不会引发错误.
That statement drops the table if it exists but will not throw an error if it does not.
这篇关于如果表存在,则放下表,然后创建它;如果不存在,则创建它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文