MySQL “CREATE TABLE IF NOT EXISTS” -> Error 1050

后端 未结 9 1477
温柔的废话
温柔的废话 2021-02-01 00:16

Using the command:

CREATE TABLE IF NOT EXISTS `test`.`t1` (
    `col` VARCHAR(16) NOT NULL
) ENGINE=MEMORY;

Running this twice in the MySQL Que

相关标签:
9条回答
  • 2021-02-01 00:58

    If anyone is getting this error after a Phpmyadmin export, using the custom options and adding the "drop tables" statements cleared this right up.

    0 讨论(0)
  • 2021-02-01 00:59

    As already stated, it's a warning not an error, but (if like me) you want things to run without warnings, you can disable that warning, then re-enable it again when you're done.

    SET sql_notes = 0;      -- Temporarily disable the "Table already exists" warning
    CREATE TABLE IF NOT EXISTS ...
    SET sql_notes = 1;      -- And then re-enable the warning again
    
    0 讨论(0)
  • 2021-02-01 01:03

    Create mysql connection with following parameter. "'raise_on_warnings': False". It will ignore the warning. e.g.

    config = {'user': 'user','password': 'passwd','host': 'localhost','database': 'db',   'raise_on_warnings': False,}
    cnx = mysql.connector.connect(**config)
    
    0 讨论(0)
提交回复
热议问题