首页 > 解决方案 > SQL Syntax errors in VS Code in local vs remote host

问题描述

I'm trying to containerize an app so I'm trying to write an init file for a MariaDB database for an existing database that exists on a remote server. I'm using VS Code to connect to the remote server and the .sql file with the contents of the dump has no errors, but when I try and copy it to a different workspace on my local computer, I get many syntax errors.

Examples of the syntax errors:

DROP TABLE IF EXISTS `accounts`;
CREATE TABLE `accounts` (
  `table_number` int(11) NOT NULL AUTO_INCREMENT, 
  `account_id` varchar(12) NOT NULL, 
  `account_name` varchar(5) NOT NULL,
  PRIMARY KEY (`table_number`)
) ENGINE=InnoDB AUTO_INCREMENT=261 DEFAULT CHARSET=latin1; 
Incorrect syntax near '`'. Expecting '(', or SELECT. 

Incorrect syntax near '11'. Expecting '(', or SELECT.

The error about the ` character is present before "accounts" and before both instances of "table_number" but not before "account_id" and "account_name". Every number in the CREATE has the incorrect syntax warning. I've tried retyping rather than copy and pasting to see if there's hidden characters responsible for these issues, but no luck.

Is this an OS issue? The remote server is a CentOS machine and my local is macOS Catalina. A setting in VS Code I need to specify or change?

标签: mysqlvisual-studio-codemariadb

解决方案


推荐阅读