创建表时设置表名“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