简体   繁体   English

Maria DB服务器

[英]Maria DB Server

I land up in an error stating: 我出现了一个错误,指出:

Error Code 1064: You have an error in your sqlsyntax; 错误代码1064:您的sqlsyntax中有一个错误。 check the manual that corresponds to your MariaDB Server syntax for the right syntax to use 检查与您的MariaDB Server语法相对应的手册以使用正确的语法

CREATE TABLE 'company'.'employee'(
'fname' VARCHAR (10) NOT NULL,
'mname' VARCHAR(2) NULL, 
'lname' VARCHAR(10) NOT NULL,
'ssn' CHAR(9) NOT NULL, 
'bdate' DATE,
'address' VARCHAR(20) NOT NULL,
'sex' CHAR NULL,
'salary' DECIMAL (10, 2) NULL,
'super_ssn' CHAR(9) NULL,
'd_no' INT NOT NULL,
PRIMARY KEY ('ssn'));

Use ` instead of ' (single quote), 使用`代替' (单引号),

You should write it like the following : 您应该这样写:

    CREATE TABLE `company`.`employee`(
      `fname` VARCHAR (10) NOT NULL,
      `mname` VARCHAR(2) NULL,
      `lname` VARCHAR(10) NOT NULL,
      `ssn` CHAR(9) NOT NULL,
      `bdate` DATE,
      `address` VARCHAR(20) NOT NULL,
      `sex` CHAR NULL,
      `salary` DECIMAL (10, 2) NULL,
      `super_ssn` CHAR(9) NULL,
      `d_no` INT NOT NULL,
      PRIMARY KEY (`ssn`)
    );

Actually, the ` symbol is optional, but it is used if the field names, tables, or databases are the same as keywords or MySQL clauses whose purpose is that MySQL is not confused with what you mean in the query. 实际上,`符号是可选的,但如果字段名称,表或数据库与关键字或MySQL子句相同,则使用该符号,其目的是使MySQL与查询中的含义不混淆。

For example : 例如 :

SELECT column FROM `char`

I use ` symbol because the name of the table is the same as keyword on MySQL ie CHAR() (but naming like that is a bad way), so keep in mind that if you write SQL Query you must decide to use the ` symbol 我使用`符号,因为表的名称与MySQL上的关键字相同,即CHAR() (但是这样命名是一种不好的方式),因此请记住,如果编写SQL查询,则必须决定使用`符号

hope this can help you. 希望这可以帮到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM