开发者

Whats wrong with this CREATE TABLE statement?

开发者 https://www.devze.com 2022-12-13 01:16 出处:网络
CREATE TABLE findings ( ident VARCHAR(28), code VARCHAR(8), when DATETIME, ip VARCHAR(15) );开发者_如何学Go
CREATE TABLE findings (
  ident VARCHAR(28), 
  code VARCHAR(8), 
  when DATETIME, 
  ip VARCHAR(15)
);开发者_如何学Go


when is a keyword in mysql and needs to be quoted with backticks:

CREATE TABLE `findings` (
    `ident` VARCHAR(28),
    `code` VARCHAR(8),
    `when` DATETIME,
    `ip` VARCHAR(15)
);

EDIT: It has been pointed out correctly in the comments, that this is not a good solution. You might be better off finding another name for your column.


The word when.

In some databases this is a keyword. So, while processing your create table instruction you may get some errors from your database management system.


if you are so keen on using when just prefix the column name with _.


BTW, is not a good idea to use reserved names for rows names, tables, etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消