문제

In SQL Server I used the following code to drop a table with a constraint:

IF OBJECT_ID('EMPLOYEES') IS NOT NULL
  BEGIN
         ALTER TABLE EMPLOYEES DROP CONSTRAINT EMP_DEPT_FK
         DROP TABLE EMPLOYEES;
  END

How can I accomplish the same thing in Mysql?

도움이 되었습니까?

해결책

You can use information_schema to check if the table exists but in MySQL there is a simpler method:

DROP TABLE IF EXISTS employees ;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top