1.先建一個表,正常可以建
mysql> create table course(
-> course_no char(6) not null primary key
-> );
Query OK, 0 rows affected
2.刪掉
mysql> drop table course;
Query OK, 0 rows affected
3.復制第一步的方法建表,但是報錯了
mysql> create table course(
-> course_no char(6) not null primary key
-> );
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 '-> course_no char(6) not null primary key
-> )' at line 2
4.把not null 和primary key 的順序交換一下,結果可以
mysql> create table course(
-> course_no char(6) primary key not null
-> );
Query OK, 0 rows affected
這是為什么???
uj5u.com熱心網友回復:
語法問題嘛。先是鍵值型別申明,再是值是否為空定義。
這有啥不明白的
uj5u.com熱心網友回復:
mysql8.0實測,沒遇到你的報錯,第一次成功,按道理洗掉后重新使用一樣的陳述句創建,也會成功;轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/273057.html
標籤:基礎類
