MySQL说:#1005无法创建表“ gennet”,“ ops”(错误号:150“外键约束格式不正确)

时间:2019-07-11 11:17:31

标签: mysql sql

我正在尝试导入.sql文件。除最后一段代码外,该文件已完全导入,从而使用户可以访问该网站。

我曾尝试与此类用户手动创建表,但未成功。我已经到处搜寻了,但没有答案与我的问题有关。

如果存在ops,则删除表; 创建表ops(   id int(11)NOT NULL AUTO_INCREMENT,   user_id int(11)NOT NULL,   title varchar(255)NOT NULL,   text长文本NOT NULL,   image varchar(50)NOT NULL,   location varchar(255)NOT NULL,   start_date varchar(20)NOT NULL,   end_date varchar(20)NOT NULL,   slug varchar(255)NOT NULL,   datetime时间戳记非NULL DEFAULT CURRENT_TIMESTAMP,   主键(id),   键user_iduser_id),   约束ops_ibfk_1外键(user_id)参考usersid)在删除级联上在更新级联上 )ENGINE = InnoDB DEFAULT CHARSET = utf8;

如果存在users,则删除表; 创建表users(   id int(11)NOT NULL AUTO_INCREMENT,   firstname varchar(70)NOT NULL,   lastname varchar(70)NOT NULL,   email varchar(70)NOT NULL,   password varchar(50)NOT NULL,   phone varchar(30)NOT NULL,   publication_name varchar(255)NOT NULL,   media_type varchar(70)NOT NULL,   published_country varchar(70)NOT NULL,   age_range varchar(50)NOT NULL,   hobbies varchar(70)NOT NULL,   website varchar(255)NOT NULL,   company varchar(70)NOT NULL,   about文字NOT NULL,   image varchar(50)NOT NULL,   type int(11)NOT NULL,   demographic_cis_male varchar(10)NOT NULL缺省为'0',   demographic_cis_female varchar(10)NOT NULL缺省为'0',   demographic_non_binary varchar(10)NOT NULL缺省为'0',   demographic_transgender_male varchar(10)NOT NULL缺省为'0',   demographic_transgender_female varchar(10)NOT NULL缺省为'0',   demographic_lesbian varchar(10)NOT NULL缺省为'0',   demographic_gay varchar(10)NOT NULL缺省为'0',   demographic_bisexual varchar(10)NOT NULL缺省为'0',   demographic_transgender varchar(10)NOT NULL缺省为'0',   demographic_bame varchar(10)NOT NULL缺省为'0',   ar_16_24 varchar(10)NOT NULL缺省为'0',   ar_25_34 varchar(10)NOT NULL缺省为'0',   ar_35_44 varchar(10)NOT NULL缺省为'0',   ar_45_54 varchar(10)NOT NULL缺省为'0',   ar_55_64 varchar(10)NOT NULL缺省为'0',   ar_65_plus varchar(10)NOT NULL缺省为'0',   print_readership varchar(50)NOT NULL缺省为'0',   news_letter_readership varchar(50)NOT NULL缺省为'0',   readership_income_currency varchar(100)NOT NULL缺省值'0',   readership_income_percentage varchar(50)NOT NULL缺省为'0',   social_demographic1_name varchar(50)NOT NULL,   social_demographic1_value varchar(50)NOT NULL缺省为'0',   social_demographic2_name varchar(50)NOT NULL,   social_demographic2_value varchar(50)NOT NULL缺省为'0',   social_demographic3_name varchar(50)NOT NULL,   social_demographic3_value varchar(50)NOT NULL缺省为'0',   social_demographic4_name varchar(50)NOT NULL,   social_demographic4_value varchar(50)NOT NULL缺省为'0',   social_demographic5_name varchar(50)NOT NULL,   social_demographic5_value varchar(50)NOT NULL缺省为'0',   online_unique_visitors varchar(50)NOT NULL缺省为'0',   facebook_following varchar(50)NOT NULL缺省为'0',   twitter_following varchar(50)NOT NULL缺省为'0',   instagram_following varchar(50)NOT NULL缺省为'0',   youtube_following varchar(50)NOT NULL缺省为'0',   snapchat_following varchar(50)NOT NULL缺省为'0',   pintrest_following varchar(50)NOT NULL缺省为'0',   tumblr_following varchar(50)NOT NULL缺省为'0',   country1_name varchar(50)NOT NULL,   country1_percentage varchar(50)NOT NULL缺省为'0',   country2_name varchar(50)NOT NULL,   country2_percentage varchar(50)NOT NULL缺省为'0',   country3_name varchar(50)NOT NULL,   country3_percentage varchar(50)NOT NULL缺省为'0',   country4_name varchar(50)NOT NULL,   country4_percentage varchar(50)NOT NULL缺省为'0',   country5_name varchar(50)NOT NULL,   country5_percentage varchar(50)NOT NULL缺省为'0',   publication_published varchar(50)NOT NULL缺省为'0',   hobby_holidays varchar(50)NOT NULL缺省为'0',   hobby_travel varchar(50)NOT NULL缺省为'0',   hobby_grooming varchar(50)NOT NULL缺省为'0',   hobby_beauty varchar(50)NOT NULL缺省为'0',   hobby_fashion varchar(50)NOT NULL缺省为'0',   hobby_shopping varchar(50)NOT NULL缺省为'0',   hobby_home_interior varchar(50)NOT NULL缺省为'0',   hobby_dining varchar(50)NOT NULL缺省为'0',   hobby_fitness varchar(50)NOT NULL缺省为'0',   hobby_socialising varchar(50)NOT NULL缺省为'0',   hobby_music varchar(50)NOT NULL缺省为'0',   hobby_tv_radio varchar(50)NOT NULL缺省为'0',   hobby1_name varchar(50)NOT NULL,   hobby1_percent varchar(50)NOT NULL缺省为'0',   hobby2_name varchar(50)NOT NULL,   hobby2_percent varchar(50)NOT NULL缺省为'0',   hobby3_name varchar(50)NOT NULL,   hobby3_percent varchar(50)NOT NULL缺省为'0',   time_0600_1159 varchar(50)NOT NULL缺省为'0',   time_1200_1559 varchar(50)NOT NULL缺省为'0',   time_1600_1759 varchar(50)NOT NULL缺省为'0',   time_1800_2159 varchar(50)NOT NULL缺省为'0',   time_2200_0559 varchar(50)NOT NULL缺省为'0',   time_others varchar(50)NOT NULL缺省为'0',   listeners varchar(50)NOT NULL缺省为'0',   listeners_income_currency varchar(50)NOT NULL缺省为'0',   listeners_income_percentage varchar(50)NOT NULL缺省为'0',   viewership varchar(50)NOT NULL缺省为'0',   viewership_income_currency varchar(50)NOT NULL缺省为'0',   viewership_income_percentage varchar(50)NOT NULL缺省为'0',   ban int(1)非空默认值'0',   datetime时间戳记非NULL DEFAULT CURRENT_TIMESTAMP,   主键(id),   键typetype),   约束users_ibfk_1外键(type)参考users_typesid)在删除级联上在更新级联上 )ENGINE = InnoDB DEFAULT CHARSET = utf8;

如果存在users_types,则删除表; 创建表users_types(   id int(11)NOT NULL AUTO_INCREMENT,   type varchar(50)NOT NULL,   主键(id) )ENGINE = InnoDB DEFAULT CHARSET = utf8;

该代码应允许用户能够登录/登出网站,或者至少我应该能够登录。

0 个答案:

没有答案