简体   繁体   中英

Syntax error creating a table in my database

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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