简体   繁体   中英

PLese what is wrong with mySql syntax

CREATE TABLE users(
    user_id int(11)  auto_increment primary key,
    f_name VARCHAR(255) NOT NULL,
    l_name VARCHAR(255) not NULL,
    u_name VARCHAR NOT NULL UNIQUE,
    phone int(15) not null UNIQUE,
    email VARCHAR not null UNIQUE,
    pwd VARCHAR not null,
    confpwd VARCHAR not null,
    state VARCHAR(255),
    lga VARCHAR(255) DEFAULT null,
    preference enum('m','f','mf') DEFAULT 'mf',
    gender enum('m','f') DEFAULT null,
    profile_image VARCHAR(255),
    bio VARCHAR(1000) DEFAULT null,
    forgot_pwd_code VARCHAR (255),
    forgot_pwd_time TIMESTAMP DEFAULT NULL,
    created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    hobbies_id int(11),
     FOREIGN KEY (hobbies_id) REFERENCES hobbies (userId) ON DELETE NO ACTION ON UPDATE NO ACTION
)  ENGINE=InnoDB DEFAULT CHARSET=latin1;

i keep getting this error

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 'NOT NULL UNIQUE, phone int(15) not null UNIQUE, email VARCHAR not null' at line 5

The VARCHAR datatypes requires a length (that represents the maximum number of characters allowed) - not providing it is a syntax error.

This is true not only for column uname , but for also for pwd and confpwd . Each of these columns should be declared like varchar(<N>) , where <N> is the length of the column, instead of just varchar .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM