Home > Software design >  Syntax error creating a table in my database
Syntax error creating a table in my database

Time:12-31

I'm getting error after trying to create a table for my data base

This is my script

CREATE TABLE `users` (
  `id` int PRIMARY KEY NOT NULL AUTO_INCREMENT,
  `user_role_id` int NOT NULL,
  `first_name` varchar(250) NOT NULL,
  `last_name` varchar(250) NOT NULL,
  `name` varchar(250),
  `email` varchar(250) NOT NULL,
  `dni_type` varchar(32) NOT NULL,
  `dni` int NOT NULL,
  `phone` int,
  `address` varchar(250),
  `city` varchar(125),
  `state` varchar(125),
  `country` varchar(32),
  `zip` varchar(32),
  `created_at` datetime,
  `created_by` int,
  `updated_at` datetime,
  `updated_by` int,
  `deleted_at` datetime,
  `deleted_by` int
);

I'm getting

#1064 - Something is wrong in your syntax near 'CREATE TABLE `users` (
  `id` int PRIMARY KEY NOT NULL AUTO_INCREMENT,
  `u...' on line 2

Why is the error generated, and how can I avoid it in the future?

CodePudding user response:

CREATE TABLE users ( id int PRIMARY KEY NOT NULL AUTO_INCREMENT

Don't use `

CREATE TABLE users ( id int PRIMARY KEY NOT NULL AUTO_INCREMENT

  • Related