錯誤 1064 (42000):在零填充列中出現 SQL 語法錯誤?
以下是錯誤,當您錯誤地實現 ZEROFILL 時會出現該錯誤。
mysql> create table DemoTable -> ( -> StudentCode int(10) NOT NULL ZEROFILL AUTO_INCREMENT PRIMARY KEY -> ); ERROR 1064 (42000): 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 'ZEROFILL AUTO_INCREMENT PRIMARY KEY )' at line 3
若要正確實現,請使用以下語法:
語法
yourColumnName int(10) ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY
首先,讓我們建立一個表:
mysql> create table DemoTable -> ( -> StudentCode int(10) ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY -> ); Query OK, 0 rows affected (0.55 sec)
使用 insert 命令在表中插入一些記錄:
mysql> insert into DemoTable values(); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.10 sec)
使用 select 語句從表中顯示所有記錄:
mysql> select *from DemoTable;
這將產生以下輸出:
+-------------+ | StudentCode | +-------------+ | 0000000001 | | 0000000002 | | 0000000003 | | 0000000004 | | 0000000005 | +-------------+ 5 rows in set (0.00 sec)
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP