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

后端 未结 9 1493
温柔的废话
温柔的废话 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:53

    You can use the following query to create a table to a particular database in MySql.

    create database if not exists `test`;
    
    USE `test`;
    
    SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
    
    /*Table structure for table `test` */
    
    CREATE TABLE IF NOT EXISTS `tblsample` (
    
      `id` int(11) NOT NULL auto_increment,   
      `recid` int(11) NOT NULL default '0',       
      `cvfilename` varchar(250)  NOT NULL default '',     
      `cvpagenumber`  int(11) NULL,     
      `cilineno` int(11)  NULL,    
      `batchname`  varchar(100) NOT NULL default '',
      `type` varchar(20) NOT NULL default '',    
      `data` varchar(100) NOT NULL default '',
       PRIMARY KEY  (`id`)
    
    );
    

提交回复
热议问题