我正在创建一个带有事件的总线表来维护数据。如果总线表中不存在记录,是否可以通过DropBusEvent事件丢弃该表和autoDelete事件?
stt.execute("CREATE TABLE IF NOT EXISTS bus"
+ "(id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,"
+ "mac VARCHAR(30) NOT NULL UNIQUE,"
+ "route int(11) NOT NULL,"
+ "latitude FLOAT(10,6) NOT NULL,"
+ "longitude FLOAT(10,6) NOT NULL,"
+ "created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)");
stt.execute("CREATE EVENT IF NOT EXISTS AutoDelete "
+ "ON SCHEDULE EVERY 3 MINUTE "
+ "DO "
+ "DELETE FROM bus WHERE created_at < (NOW() - INTERVAL 3 MINUTE)");
// I tried this statement here but it does not work.
stt.execute("CREATE EVENT IF NOT EXITS DropBusTable "
+ "Do "
+ "DROP TABLES IF EXISTS bus");我要去找You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'EXITS DropBusTableDROP TABLES IF EXISTS bus' at line 1
发布于 2015-05-07 20:26:23
您的语法有一个错误:
行中使用EXITS而不是EXISTS
stt.execute("CREATE EVENT IF NOT EXITS DropBusTable "https://stackoverflow.com/questions/30100876
复制相似问题