简体   繁体   中英

SQL error 1064 - how to fix?

What is this?

SQL query: 

ALTER TABLE `ads` ADD `ad_title` VARCHAR NOT NULL 

MySQL said:  
 #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL' at line 1

Query is generated by phpmyadmin

您没有为VARCHAR分配长度。

The syntax error in this sentence lies in the type definition of the column. It should specify the maximum length of the VARCHAR column.

ALTER TABLE `ads` ADD `ad_title` VARCHAR(10) NOT NULL 

It is working in this sqlfiddle .

See the following example, where length 50 is assigned to columns First_Name and Surname :

在此处输入图片说明

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