Hello,
To create a new repo wizard which requires mySQL I always get error, upon running the errors via chatGPT I get some solution , but not wholly
I swear if we could upgrade our MSSql it would be so much easier and better
The formatting is completely messed up below, I can't figure why
Error 1
Code:
CREATE TABLE 'GROUPS' ( GROUP_ID NUMERIC NOT NULL , GROUP_NAME NVARCHAR(80) DEFAULT NULL, CREATED DATETIME DEFAULT NULL, CREATED_BY NVARCHAR(32) DEFAULT NULL, CHANGED DATETIME DEFAULT NULL, CHANGED_BY NVARCHAR(32) DEFAULT NULL ) ; Following Error happened: [MySQL][ODBC 8.3(w) Driver][mysqld-8.3.0]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 'GROUPS ( GROUP_ID NUMERIC NOT NULL , GROUP_NAME NVARCHAR(80) DEFAULT NULL,' at line 1
The error you're encountering is likely due to the use of single quotes around the table name
and possibly the use of
and
types, which are not directly used in MySQL the same way they might be in other SQL databases like SQL Server. In MySQL, you should use backticks to escape reserved words or special characters in table names and column names, and use equivalent data types that MySQL supports.Here's how you can correct the syntax for MySQL:
Code:
CREATE TABLE `GROUPS` (
`GROUP_ID` INT NOT NULL,
`GROUP_NAME` VARCHAR(80) DEFAULT NULL,
`CREATED` DATETIME DEFAULT NULL,
`CREATED_BY` VARCHAR(32) DEFAULT NULL,
`CHANGED` DATETIME DEFAULT NULL,
`CHANGED_BY` VARCHAR(32) DEFAULT NULL
);
I corrected multiple errors on the same
ALTER TABLE ACCESS_RIGHTS ADD CONSTRAINT FK_ACCESS_RIGHTS_GROUPS FOREIGN KEY ( GROUP_ID ) REFERENCES GROUPS ( GROUP_ID ) ON DELETE CASCADE ; Following Error happened: [MySQL][ODBC 8.3(w) Driver][mysqld-8.3.0]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 'GROUPS ( GROUP_ID ) ON DELETE CASCADE' at line 7
ChatGPT suggested code Fails
Code:
ALTER TABLE `ACCESS_RIGHTS` ADD CONSTRAINT `FK_ACCESS_RIGHTS_GROUPS` FOREIGN KEY (`GROUP_ID`) REFERENCES `GROUPS` (`GROUP_ID`) ON DELETE CASCADE;
ALTER TABLE `ACCESS_RIGHTS` ADD CONSTRAINT `FK_ACCESS_RIGHTS_GROUPS` FOREIGN KEY (`GROUP_ID`) REFERENCES `GROUPS` (`GROUP_ID`) ON DELETE CASCADE;