简体   繁体   中英

Facing error while Creating a SQL table in MySQL

MySQL is throwing error back without specifying what the error is. It's throwing this statement back

ERROR: syntax error at or near "(" LINE 2: "order_id" INT(10) NOT NULL, ^

My Code for creating the table is:

CREATE TABLE dispatch (
   "order_id" INT(10) NOT NULL,
   "order_created_at"" DATETIME ,
   "order_number"" VARCHAR(30),
   "shipment_fc"" TINYTEXT,
   "shipment_priority"" TINYTEXT,
   "shipment_id"" INT(10),
   "shipment_status"" TINYTEXT,
   "shipment_number"" VARCHAR(30),
   "orderline_id"" INT(10),
   "processed_quantity"" INT(10),
   "orderline_client_name"" VARCHAR(30),
   "updated_at"" DATETIME,
   "waybill_created_at"" DATETIME,
   "child_waybill"" INT,
   "master_waybill"" INT,
   "shipped_at"" DATETIME,
   "cpt"" DATETIME,
   "diff"" FLOAT,
   "tat"" TINYTEXT,
   PRIMARY KEY ("order_id")
)

I have based if of the example code MySQL provides before table creation:

CREATE TABLE schema.table_name (
   "field_1" INT(10) NOT NULL,
   "field_2"" VARCHAR(20),
   "field_3"" DATETIME,
   "field_4"" TEXT,
   "field_5"" BLOB,
   PRIMARY KEY ("field_1")
)
[WITH OIDS|WITHOUT OIDS]

Any help would be appreciated.

You need to remove double quotes and then it should work.

CREATE TABLE dispatch (
   order_id INT(10) NOT NULL,
   order_created_at DATETIME ,
   order_number VARCHAR(30),
   shipment_fc TINYTEXT,
   shipment_priority TINYTEXT,
   shipment_id INT(10),
   shipment_status TINYTEXT,
   shipment_number VARCHAR(30),
   orderline_id INT(10),
   processed_quantity INT(10),
   orderline_client_name VARCHAR(30),
   updated_at DATETIME,
   waybill_created_at DATETIME,
   child_waybill INT,
   master_waybill INT,
   shipped_at DATETIME,
   cpt DATETIME,
   diff FLOAT,
   tat TINYTEXT,
   PRIMARY KEY (order_id)
);
/

Here is the DEMO

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