Git Product home page Git Product logo

Comments (10)

tiancaiamao avatar tiancaiamao commented on August 17, 2024

CREATE TABLE t1 而不是 CREATE TABLE "t1" 吧?
@iamxy

from docs-cn.

soniazhai avatar soniazhai commented on August 17, 2024

这是日志里的信息,建表语句就是用的范例

from docs-cn.

IANTHEREAL avatar IANTHEREAL commented on August 17, 2024

@soniazhai 你是完全 copy 样例 来创建表的吗? 能不能提供一下你的所用的数据库以及版本,以及相关表的类似 show create table t1 的输出结果

from docs-cn.

soniazhai avatar soniazhai commented on August 17, 2024

@GregoryIan 是完全copy的,数据库是mysql ,版本Server version: 5.6.34

mysql> show create table t1;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+
| t1 | CREATE TABLE "t1" (
"id" int(11) NOT NULL DEFAULT '0',
"age" int(11) DEFAULT NULL,
PRIMARY KEY ("id")
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+

mysql> show create table t2;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| t2 | CREATE TABLE "t2" (
"id" int(11) NOT NULL DEFAULT '0',
"name" varchar(256) DEFAULT NULL,
PRIMARY KEY ("id")
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

创建时的执行记录如下:
mysql> USE test;
Database changed
mysql> CREATE TABLE t1 (id INT, age INT, PRIMARY KEY(id)) ENGINE=InnoDB;
CREATE TABLE t2 (id INT, name VARCHAR(256), PRIMARY KEY(id)) ENGINE=InnoDB;

INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
INSERT INTO t2 VALUES (1, "a"), (2, "b"), (3, "c");Query OK, 0 rows affected (0.32 sec)

mysql> CREATE TABLE t2 (id INT, name VARCHAR(256), PRIMARY KEY(id)) ENGINE=InnoDB;
Query OK, 0 rows affected (0.44 sec)

mysql>
mysql> INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
Query OK, 3 rows affected (0.06 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> INSERT INTO t2 VALUES (1, "a"), (2, "b"), (3, "c");
ERROR 1054 (42S22): Unknown column 'a' in 'field list'
mysql> INSERT INTO t2 VALUES (1, 'a'), (2, 'b'), (3, 'c');
Query OK, 3 rows affected (0.05 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> select * from t1;
+----+------+
| id | age |
+----+------+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+----+------+
3 rows in set (0.00 sec)

mysql> select * from t2;
+----+------+
| id | name |
+----+------+
| 1 | a |
| 2 | b |
| 3 | c |
+----+------+
3 rows in set (0.00 sec)

from docs-cn.

IANTHEREAL avatar IANTHEREAL commented on August 17, 2024

@soniazhai 你可以查看一下 SHOW VARIABLES LIKE '%sql_mode%'; 是否是 ANSI_QUOTES;TiDB 不支持用双引号当作 identifier quote character.

from docs-cn.

soniazhai avatar soniazhai commented on August 17, 2024

mysql> SHOW VARIABLES LIKE '%sql_mode%';
+---------------+------------------------------------------------------------------------+
| Variable_name | Value |
+---------------+------------------------------------------------------------------------+
| sql_mode | PIPES_AS_CONCAT,ANSI_QUOTES,STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
+---------------+------------------------------------------------------------------------+
1 row in set (0.00 sec)

from docs-cn.

soniazhai avatar soniazhai commented on August 17, 2024

@GregoryIan 在上面范例执行时,插入数据也报过错,就是双引号的问题。

from docs-cn.

soniazhai avatar soniazhai commented on August 17, 2024

@GregoryIan确实改了变量后,check通过了,thanks!

from docs-cn.

tiancaiamao avatar tiancaiamao commented on August 17, 2024

TiDB 不支持用双引号当作 identifier quote character.

更正,TiDB这边是支持的,可以设置 ANSI_QUOTES 变量来实现。

from docs-cn.

soniazhai avatar soniazhai commented on August 17, 2024

@tiancaiamao 我之前是设置ANSI_QUOTES了的,但执行check报错,现在把ANSI_QUOTES去掉执行check成功了

from docs-cn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.