Re: Error Code: 1146 when creating new table desc
Three syntax errors ...
1 VISIBLE in the unique index
MySQL doesn't seem to like VISIBLE or INVISIBLE in CREATE TABLE, I'm unsure why. For creating an invisible index, this works ...
create table x( ..., unique index key_f(f), ...);
ALTER INDEX key_f INVISIBLE;
But in your case, VISIBLE is the default so it's not needed.
2 Missing semicolon at the end of the Create Table stmt
3 In the Insert stmt, SELECT instead of a left parenthesis at the beginning of the column list
In general, the soundest way to write an error-free script is to compose each stmt in a text editor, test it in the mysql command client or you if you prefer mysqlsh or workbench, add it to the script once it's debugged.
Even better, if the script might be run without supervision by an experienced MySQL developer, assemble the debugged code in a stored procedure with DECLARE EXIT HANDLER and SIGNAL commands for error handling.
Edited 1 time(s). Last edit at 06/26/2022 03:03PM by Peter Brawley.