I have successfully backup sql database. But whenever trying to import it shows some error. Like below:
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'STORED,
`purchase_gst` decimal(10,2) NOT NULL,
`purchase_due` decimal(10,2' at line 8
Here is my code extracted from SQL file:
DROP TABLE IF EXISTS `purchase`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `purchase` (
`purchase_id` bigint(20) NOT NULL AUTO_INCREMENT,
`purchase_date` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`purchase_item` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`purchase_rate` decimal(10,2) DEFAULT NULL,
`purchase_qty` decimal(10,2) NOT NULL,
`purchase_from` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`purchase_gross` decimal(10,2) GENERATED ALWAYS AS ((`purchase_qty` * `purchase_rate`)) STORED,
`purchase_gst` decimal(10,2) NOT NULL,
`purchase_due` decimal(10,2) NOT NULL,
`purchase_tcost` decimal(10,2) NOT NULL,
`purchase_net` decimal(10,0) GENERATED ALWAYS AS (round(((`purchase_gross` + `purchase_gst`) + `purchase_tcost`),0)) STORED,
PRIMARY KEY (`purchase_id`)
) ENGINE=InnoDB AUTO_INCREMENT=372 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
2
Answers
Please check the version of MySQl .This will work on MySQl 5.7 and above versions.
It’s depends on your mySql version.
This sql syntax error shows below the MySQL 5.7 version.
Please Check this with in MySQL 5.7 version it’s working with below code: