建立表時設定表名“references”時,將出現錯誤
你無法給表名引用,因為它是一個保留關鍵字。用反引號將它包起來,例如,`references`。
讓我們先建立一個表格 -
mysql> create table `references`(Subject text); Query OK, 0 rows affected (0.44 sec)
使用 insert 命令在表中插入一些記錄 -
mysql> insert into `references` values('Introduction To MySQL');
Query OK, 1 row affected (0.28 sec)
mysql> insert into `references` values('Introduction To MongoDB');
Query OK, 1 row affected (0.15 sec)
mysql> insert into `references` values('Introduction To Spring and Hibernate');
Query OK, 1 row affected (0.13 sec)
mysql> insert into `references` values('Introduction To Java');
Query OK, 1 row affected (0.18 sec)使用 select 語句顯示錶中的所有記錄 -
mysql> select *from `references`;
這將產生以下輸出 -
+--------------------------------------+ | Subject | +--------------------------------------+ | Introduction To MySQL | | Introduction To MongoDB | | Introduction To Spring and Hibernate | | Introduction To Java | +--------------------------------------+ 4 rows in set (0.00 sec)
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP