Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如果不存在,请按名称检查表_Mysql - Fatal编程技术网

Mysql 如果不存在,请按名称检查表

Mysql 如果不存在,请按名称检查表,mysql,Mysql,我想用mysql为敏捷数据库开发创建幂等脚本。如果您想了解它,请访问以下链接: 如果存在drop table,则此操作是错误的。我在找这样的东西: IF NOT EXISTS ( SELECT * FROM information_schema.tables WHERE table_schema = 'foo' AND table_name = 'customer' LIMIT 1; ) BEGIN CREATE TABLE customer(n

我想用mysql为敏捷数据库开发创建幂等脚本。如果您想了解它,请访问以下链接:

如果存在drop table,则此操作是错误的。我在找这样的东西:

IF NOT EXISTS
(
    SELECT *
    FROM information_schema.tables
    WHERE table_schema = 'foo'
    AND table_name = 'customer'
    LIMIT 1;
)
BEGIN
    CREATE TABLE customer(n int);
END
如果有帮助,我正在寻找以下功能:

If Not exists something
then
    statement1
    statement2
    ...
    statementN
else
    do nothing
fi 

请参见

您应该能够在存储过程中执行此操作。无需存储过程;这是
CREATE TABLE
附带的一项基本功能。哦,请阅读手册!!这对我的要求不起作用。脚本需要是幂等的,但不行。这不是瓷器店里的牛。如果不存在,则执行N个步骤,而不仅仅是一个步骤。
CREATE TABLE IF NOT EXISTS customer
    (n int);