MySQL: Can't create table (errno: 150)

后端 未结 30 2639
误落风尘
误落风尘 2020-11-22 06:48

I am trying to import a .sql file and its failing on creating tables.

Here\'s the query that fails:

CREATE TABLE `data` (
`id` int(10) unsigned NOT NUL         


        
30条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 07:12

    I faced this kind of issue while creating DB from the textfile.

    mysql -uroot -padmin < E:\important\sampdb\createdb.sql
    mysql -uroot -padmin sampdb < E:\important\sampdb\create_student.sql
    mysql -uroot -padmin sampdb < E:\important\sampdb\create_absence.sql
    
    mysql -uroot -padmin sampdb < E:\important\sampdb\insert_student.sql
    mysql -uroot -padmin sampdb < E:\important\sampdb\insert_absence.sql
    
    mysql -uroot -padmin sampdb < E:\important\sampdb\load_student.sql
    mysql -uroot -padmin sampdb < E:\important\sampdb\load_absence.sql 
    

    I just wrote the above lines in Create.batand run the bat file.

    My mistake is in the sequence order of execution in my sql files. I tried to create table with primary key and also foreign key. While its running it will search for the reference table but tables are not there. So it will return those kind of error.

    If you creating tables with foreign key then check the reference tables were present or not. And also check the name of the reference tables and fields.

提交回复
热议问题