SQL 查询创建 Table 错误

SQL Query Create Table Error

我收到此错误消息:

#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 'NOT NULL,
full_name varchar,
first_name varchar,
last_name varchar,
email va' at line 2

create table ABC_CAFE(
    fb_id varchar NOT NULL,
    full_name varchar,
    first_name varchar,
    last_name varchar,
    email varchar,
    gender varchar,
    age_range varchar,
    link varchar,
    locale varchar,
    updated_time varchar,
    timezone varchar,
    verified varchar,
    url varchar,
    date_time varchar NOT NULL,
    device varchar,
    device_brand varchar,
    operating_system varchar,
    browser_name varchar,
    CONSTRAINT ID_DATE_TIME_KEY PRIMARY KEY (fb_id,date_time)
);

定义varchar列时必须指定长度。例如:

create table ABC_CAFE(
    fb_id varchar(10) NOT NULL, -- E.g., here
    full_name varchar(10),
    first_name varchar(10),
    last_name varchar(10),
    email varchar(10),
    gender varchar(10),
    age_range varchar(10),
    link varchar(10),
    locale varchar(10),
    updated_time varchar(10),
    timezone varchar(10),
    verified varchar(10),
    url varchar(10),
    date_time varchar(10) NOT NULL,
    device varchar(10),
    device_brand varchar(10),
    operating_system varchar(10),
    browser_name varchar(10),
    CONSTRAINT ID_DATE_TIME_KEY PRIMARY KEY (fb_id, date_time)
)

varchar 提供列大小,例如 varchar(50)

工作 SQL fiddle 添加列大小后:http://sqlfiddle.com/#!9/a06419


编辑:

对于我添加的示例 varchar(50),您可以根据每列的要求 increase/reduce 列大小。

您应该像 varchar(20) 那样指定 varchar 字段的长度

Varchar 要求您指定字符串的长度。

full_name varchar(10)

将指定 full_name 列最多包含 10 个字符。