Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats wrong with this CREATE TABLE statement?

Tags:

mysql

CREATE TABLE findings (
  ident VARCHAR(28), 
  code VARCHAR(8), 
  when DATETIME, 
  ip VARCHAR(15)
);
like image 461
Nathan Avatar asked Aug 03 '26 03:08

Nathan


2 Answers

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.

like image 89
soulmerge Avatar answered Aug 05 '26 19:08

soulmerge


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.

like image 20
Kico Lobo Avatar answered Aug 05 '26 19:08

Kico Lobo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!