mysql - How to generate foreign key names random which are not exist in database? -



mysql - How to generate foreign key names random which are not exist in database? -

suppose writing query this.

set foreign_key_checks = 0; alter table `studentsubjectmarkmap` add together constraint `here_i_want_some_random_name` foreign key (`id` ) references `subject` (`subjectid` ) on delete no action on update no action , add together index `here_i_want_some_random_name` (`id` asc); set foreign_key_checks = 1;

my question "is possible generate random string name foreign key name?" want such thing because query giving me duplicate key name error after dropped key name.

index name optional, don't need specify it. in case mysql assign name index , doesn't fail. see alter table syntax more details:

alter [online | offline] [ignore] table tbl_name [alter_specification [, alter_specification] ...] [partition_options] add together {index|key} [index_name] [index_type] (index_col_name,...) [index_option] ... add together [constraint [symbol]] foreign key [index_name] (index_col_name,...) reference_definition

mysql random generic-foreign-key

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -