In the MySQL team we are currently considering a proposal to deprecate a number of alternative syntax uses with the INSERT and REPLACE commands. To provide examples:
CREATE TABLE `city` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Name` char(35) NOT NULL DEFAULT '', `CountryCode` char(3) NOT NULL DEFAULT '', `District` char(20) NOT NULL DEFAULT '', `Population` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`), KEY `CountryCode` (`CountryCode`), CONSTRAINT `city_ibfk_1` FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`) ) ENGINE=InnoDB AUTO_INCREMENT=4080 DEFAULT CHARSET=latin1; INSERT INTO city SET Name='NewCity', CountryCode='CAN',District='MyDistrict',Population=1234; INSERT INTO city (Name,CountryCode,District,Population) VALUE ('NewCity2', 'CAN', 'MyDistrict', 1234); INSERT city (Name,CountryCode,District,Population) VALUES ('NewCity3', 'CAN', 'MyDistrict', 1234); REPLACE INTO city (Name,CountryCode,District,Population) VALUE ('NewCity4', 'CAN', 'MyDistrict', 1234); REPLACE city (Name,CountryCode,District,Population) VALUES ('NewCity5', 'CAN', 'MyDistrict', 1234);
To summarize these queries:
- INSERT using the SET syntax.
- INSERT and REPLACE using the keyword VALUE instead of VALUES
- INSERT and REPLACE without the keyword INTO
Our rationale for this proposal is as follows:
-
Having a number of very similar ways of completing the same task makes it very difficult for training, documentation and support. To explain this in more detail: in our manual we have always tried to document every option that the server will accept, but with no functional difference between the options, this makes the content more verbose and clumsy to read.
MySQL usage becomes cleaner by stating which usage is explicitly preferred, even if the old syntax remains supported for the legacy use-case.
- The syntax is non-standard and complicates our parser. While it may take some time before we are able to remove these options, by starting the deprecation cycle now we can provide application authors with as much notice as possible.
Our proposed plan is to deprecate the syntax starting with MySQL 5.7. We will assess feedback from our users before targeting a version for syntax removal.
Will you be affected by this change? Please leave a comment, or Get in touch! We’d love to hear from you.