Quotation restrictions only if they exist in mysql server 5.0

I want to know how to remove a restriction only if it exists. is there any single row statement present in the mysql server that will allow me to do this.

I tried the following command, but could not get the output of desire

alter table airlines drop foreign key if exits FK_airlines; 

any help on this really helps me move forward in mysql

+4
source share
2 answers

I do not think this is possible on one line if you are not ready to detect an error and move on (not so bad).

The INFORMATION_SCHEMA database contains the information necessary to indicate the presence of a foreign key so that you can implement it in a two-step process.

http://dev.mysql.com/doc/refman/5.1/en/table-constraints-table.html

+1
source

yep is impossible, if it exists, is available only for the database table and view: http://dev.mysql.com/doc/refman/5.0/en/replication-features-drop-if-exists.html

yep 2-step process is a good way, as gahooa said

0
source

Source: https://habr.com/ru/post/957554/


All Articles