这个用于创建 table 的简单 SQL 查询中的语法错误是什么?

What is the syntax error in this simple SQL query for creating a table?

我正在尝试使用 IntelliJ 的 DataGrip 在 MariaDB 数据库上做一些SQL工作。

我无法执行由 DataGrip 本身自动创建的查询....

你能帮我找出其中的错误吗?

create table currencyIndex
(
    id int auto_increment,
    isoCode VARCHAR2(3) not null,
    isoCodeNumeric SMALLINT not null,
    currencyName VARCHAR2(100) not null,
    countryName VARCHAR2(100) not null,
    constraint currencyIndex_pk
        primary key (id)
);

错误是

[42000][1064] (conn=246) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(3) not null,
[42000][1064] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(3) not null,
    isoCodeNumeric SMALLINT not null,
    currencyName VARCHAR2(100) ...' at line 4.

我尝试使用在线验证器验证查询,看起来不错...有什么建议吗?

MariaDB 和 MySQL 没有 VARCHAR2 类型(但 Oracle 有)。使用普通 VARCHAR 错误应该消失:

CREATE TABLE currencyIndex (
    id INT AUTO_INCREMENT,
    isoCode VARCHAR(3) NOT NULL,
    isoCodeNumeric SMALLINT NOT NULL,
    currencyName VARCHAR(100) NOT NULL,
    countryName VARCHAR(100) NOT NULL,
    CONSTRAINT currencyIndex_pk PRIMARY KEY (id)
);

Demo