Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

MariaDB ERROR 4161 (HY000): Unknown Data Type

Getting an unknown data type error when I try to create tables with a foreign key. I am not sure if my syntax is wrong? The exact error message is: ERROR 4161 (HY000) at line 14: Unknown data type: ‘t_name’, meaning the P1_Player table is where the error is being thrown.

DROP TABLE IF EXISTS P1_Player;
DROP TABLE IF EXISTS P1_Plays;
DROP TABLE IF EXISTS P1_Coach;
DROP TABLE IF EXISTS P1_Game;
DROP TABLE IF EXISTS P1_Team;

create table P1_Team
       (t_name          varchar(20),
        primary key (t_name)
        );

create table P1_Player
       (fname           varchar(20),
        lname           varchar(20),
        DOB             date,
        jersey_#        int,
        t_name          varchar(20),
        primary key (fname, lname, DOB),
        foreign key (t_name) references P1_Team (t_name)
                on delete cascade
        );

create table P1_Coach
       (fname            varchar(20),
        lname            varchar(20),
        t_name           varchar(20),
        foreign key (t_name) references P1_Team (t_name)
                on delete cascade
        );

create table P1_Game
       (t_name           varchar(20),
        game_date         date,
        game_time         time,
        primary key (t_name, game_date, game_time),
        foreign key (t_name) references P1_Team (t_name)
                on delete cascade
        );
create table P1_Plays
       (t_name            varchar(20),
        game_date         date,
        game_time         time,
        primary key (t_name, game_date, game_time),
        foreign key (t_name, game_date, game_time) references P1_Game (t_name, game_date,    game_time)
                on delete cascade
        );

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The error is in jersey_# on create table P1_Player you should use the back-quote (`) if you want to use special characters in mysql/mariadb column names :

create table P1_Player
       (fname           varchar(20),
        lname           varchar(20),
        DOB             date,
        `jersey_#`        int,
        t_name          varchar(20),
        primary key (fname, lname, DOB),
        foreign key (t_name) references P1_Team (t_name)
                on delete cascade
        );
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading